@lumx/core 4.25.1-alpha.0 → 4.25.1-alpha.2

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.
Files changed (34) hide show
  1. package/components-and-utils.css +11 -0
  2. package/js/components/Combobox/ComboboxOptionTests.d.ts +3 -3
  3. package/js/components/Combobox/ComboboxPopover.d.ts +1 -1
  4. package/js/components/Combobox/constants.d.ts +0 -4
  5. package/js/components/Combobox/index.d.ts +0 -16
  6. package/js/components/Combobox/setupCombobox.d.ts +2 -2
  7. package/js/components/Combobox/setupComboboxButton.d.ts +4 -3
  8. package/js/components/Combobox/setupComboboxInput.d.ts +1 -1
  9. package/js/components/Combobox/types.d.ts +14 -127
  10. package/js/components/{Combobox/ComboboxList.d.ts → Listbox/ListboxList.d.ts} +7 -7
  11. package/js/components/{Combobox/ComboboxOption.d.ts → Listbox/ListboxOption.d.ts} +9 -9
  12. package/js/components/{Combobox/ComboboxOptionAction.d.ts → Listbox/ListboxOptionAction.d.ts} +4 -4
  13. package/js/components/{Combobox/ComboboxOptionMoreInfo.d.ts → Listbox/ListboxOptionMoreInfo.d.ts} +7 -7
  14. package/js/components/{Combobox/ComboboxOptionSkeleton.d.ts → Listbox/ListboxOptionSkeleton.d.ts} +7 -7
  15. package/js/components/{Combobox/ComboboxSection.d.ts → Listbox/ListboxSection.d.ts} +10 -10
  16. package/js/components/{Combobox/ComboboxState.d.ts → Listbox/ListboxState.d.ts} +5 -5
  17. package/js/components/Listbox/Tests.d.ts +42 -0
  18. package/js/components/Listbox/constants.d.ts +4 -0
  19. package/js/components/Listbox/index.d.ts +18 -0
  20. package/js/components/Listbox/navigation.d.ts +40 -0
  21. package/js/components/Listbox/setupListbox.d.ts +17 -0
  22. package/js/components/Listbox/subscribeListboxState.d.ts +24 -0
  23. package/js/components/Listbox/types.d.ts +146 -0
  24. package/js/components/{Combobox → Listbox}/utils.d.ts +2 -2
  25. package/js/components/Popover/Stories.d.ts +2 -2
  26. package/js/components/TimePickerField/index.d.ts +4 -4
  27. package/js/utils/select/SelectionIcon.d.ts +13 -0
  28. package/js/utils/select/renderSelectOptions.d.ts +1 -8
  29. package/lumx.css +11 -0
  30. package/package.json +2 -2
  31. package/scss/components/combobox/_index.scss +5 -0
  32. package/scss/components/list/_mixins.scss +1 -0
  33. package/js/components/Combobox/setupListbox.d.ts +0 -23
  34. package/js/components/Combobox/subscribeComboboxState.d.ts +0 -23
@@ -5076,6 +5076,9 @@ table {
5076
5076
  .lumx-combobox-option-skeleton:nth-child(3n+2) .lumx-skeleton-typography {
5077
5077
  width: min(55%, 170px);
5078
5078
  }
5079
+ .lumx-combobox-option__selection-icon {
5080
+ margin: auto;
5081
+ }
5079
5082
  .lumx-combobox-option .lumx-list-item__content {
5080
5083
  display: flex;
5081
5084
  flex-direction: column;
@@ -8123,6 +8126,7 @@ table {
8123
8126
  display: flex;
8124
8127
  flex-shrink: 0;
8125
8128
  justify-content: center;
8129
+ gap: 4px;
8126
8130
  width: 24px;
8127
8131
  margin-right: 8px;
8128
8132
  }
@@ -8130,6 +8134,7 @@ table {
8130
8134
  display: flex;
8131
8135
  flex-shrink: 0;
8132
8136
  justify-content: center;
8137
+ gap: 4px;
8133
8138
  margin-left: 8px;
8134
8139
  }
8135
8140
 
@@ -8147,6 +8152,7 @@ table {
8147
8152
  display: flex;
8148
8153
  flex-shrink: 0;
8149
8154
  justify-content: center;
8155
+ gap: 4px;
8150
8156
  width: 36px;
8151
8157
  margin-right: 16px;
8152
8158
  }
@@ -8154,6 +8160,7 @@ table {
8154
8160
  display: flex;
8155
8161
  flex-shrink: 0;
8156
8162
  justify-content: center;
8163
+ gap: 4px;
8157
8164
  margin-left: 16px;
8158
8165
  }
8159
8166
 
@@ -8171,6 +8178,7 @@ table {
8171
8178
  display: flex;
8172
8179
  flex-shrink: 0;
8173
8180
  justify-content: center;
8181
+ gap: 4px;
8174
8182
  width: 36px;
8175
8183
  margin-right: 16px;
8176
8184
  }
@@ -8178,6 +8186,7 @@ table {
8178
8186
  display: flex;
8179
8187
  flex-shrink: 0;
8180
8188
  justify-content: center;
8189
+ gap: 4px;
8181
8190
  margin-left: 16px;
8182
8191
  }
8183
8192
 
@@ -8194,6 +8203,7 @@ table {
8194
8203
  display: flex;
8195
8204
  flex-shrink: 0;
8196
8205
  justify-content: center;
8206
+ gap: 4px;
8197
8207
  width: 36px;
8198
8208
  margin-right: 16px;
8199
8209
  }
@@ -8201,6 +8211,7 @@ table {
8201
8211
  display: flex;
8202
8212
  flex-shrink: 0;
8203
8213
  justify-content: center;
8214
+ gap: 4px;
8204
8215
  margin-left: 16px;
8205
8216
  }
8206
8217
 
@@ -4,10 +4,10 @@ type RenderResult = {
4
4
  container: HTMLElement;
5
5
  };
6
6
  /**
7
- * Options to set up the ComboboxOption test suite.
7
+ * Options to set up the ListboxOption test suite.
8
8
  * Injected by the framework-specific test file (React or Vue).
9
9
  */
10
- export interface ComboboxOptionTestSetup {
10
+ export interface ListboxOptionTestSetup {
11
11
  /** Combobox compound component namespace */
12
12
  Combobox: Pick<ComboboxNamespace, 'Provider' | 'Input' | 'List' | 'Option'>;
13
13
  /**
@@ -20,5 +20,5 @@ export interface ComboboxOptionTestSetup {
20
20
  * Shared Combobox.Option test suite — covers DOM shape and ARIA correctness.
21
21
  * Runs the same assertions against both React and Vue wrappers.
22
22
  */
23
- export default function comboboxOptionTests({ Combobox, render }: ComboboxOptionTestSetup): void;
23
+ export default function listboxOptionTests({ Combobox, render }: ListboxOptionTestSetup): void;
24
24
  export {};
@@ -14,7 +14,7 @@ type InheritedPopoverProps = Pick<PopoverProps, 'closeOnClickAway' | 'closeOnEsc
14
14
  * Defines the props for the core ComboboxPopover template.
15
15
  */
16
16
  export interface ComboboxPopoverProps extends HasClassName, InheritedPopoverProps {
17
- /** Content (should contain a ComboboxList). */
17
+ /** Content (should contain a ListboxList). */
18
18
  children?: JSXElement;
19
19
  }
20
20
  /**
@@ -1,7 +1,3 @@
1
1
  import { VHSize } from '../../utils/browser/css/types';
2
- import { OptionActiveEvent } from './types';
3
2
  export declare const DEFAULT_COMBOBOX_POPOVER_MAX_HEIGHT: VHSize;
4
3
  export declare const COMBOBOX_PROVIDER_COMPONENT_NAME = "ComboboxProvider";
5
- export declare const OPTION_ACTIVE_EVENT_PREFIX: "optionActive:";
6
- export declare const optionActiveEvent: (optionId: string) => OptionActiveEvent;
7
- export declare const isOptionActiveEvent: (event: string) => event is OptionActiveEvent;
@@ -1,25 +1,9 @@
1
1
  export { setupComboboxInput } from './setupComboboxInput';
2
2
  export { setupComboboxButton } from './setupComboboxButton';
3
3
  export type { ComboboxCallbacks, ComboboxHandle } from './types';
4
- export { ComboboxList } from './ComboboxList';
5
- export type { ComboboxListProps, ComboboxListType } from './ComboboxList';
6
4
  export { ComboboxPopover } from './ComboboxPopover';
7
5
  export type { ComboboxPopoverProps, ComboboxPopoverComponents } from './ComboboxPopover';
8
- export { ComboboxOption } from './ComboboxOption';
9
- export type { ComboboxOptionProps, ComboboxOptionPropsToOverride } from './ComboboxOption';
10
- export { ComboboxOptionAction } from './ComboboxOptionAction';
11
- export type { ComboboxOptionActionProps } from './ComboboxOptionAction';
12
- export { ComboboxOptionSkeleton } from './ComboboxOptionSkeleton';
13
- export type { ComboboxOptionSkeletonProps, ComboboxOptionSkeletonPropsToOverride } from './ComboboxOptionSkeleton';
14
- export { ComboboxOptionMoreInfo } from './ComboboxOptionMoreInfo';
15
- export type { ComboboxOptionMoreInfoProps, ComboboxOptionMoreInfoPropsToOverride, ComboboxOptionMoreInfoComponents, } from './ComboboxOptionMoreInfo';
16
6
  export { ComboboxButton } from './ComboboxButton';
17
7
  export type { ComboboxButtonProps, ComboboxButtonComponents, ComboboxButtonLabelDisplayMode } from './ComboboxButton';
18
8
  export { ComboboxInput } from './ComboboxInput';
19
9
  export type { ComboboxInputProps, ComboboxInputComponents } from './ComboboxInput';
20
- export { ComboboxSection } from './ComboboxSection';
21
- export type { ComboboxSectionProps, ComboboxSectionPropsToOverride, ComboboxSectionComponents, } from './ComboboxSection';
22
- export { ComboboxState } from './ComboboxState';
23
- export type { ComboboxStateProps } from './ComboboxState';
24
- export { subscribeComboboxState } from './subscribeComboboxState';
25
- export type { ComboboxStateSetters } from './subscribeComboboxState';
@@ -1,6 +1,6 @@
1
1
  import type { ComboboxCallbacks, ComboboxHandle, OnTriggerAttach } from './types';
2
2
  /** Options for configuring the shared combobox behavior. */
3
- interface ComboboxOptions {
3
+ interface ListboxOptions {
4
4
  /** When true, ArrowDown/ArrowUp wrap around in listbox mode (input pattern). Default: false. */
5
5
  wrapNavigation?: boolean;
6
6
  }
@@ -20,5 +20,5 @@ interface ComboboxOptions {
20
20
  * attach the appropriate controller.
21
21
  * @returns A ComboboxHandle for interacting with the combobox.
22
22
  */
23
- export declare function setupCombobox(callbacks: ComboboxCallbacks, options?: ComboboxOptions, onTriggerAttach?: OnTriggerAttach): ComboboxHandle;
23
+ export declare function setupCombobox(callbacks: ComboboxCallbacks, options?: ListboxOptions, onTriggerAttach?: OnTriggerAttach): ComboboxHandle;
24
24
  export {};
@@ -4,10 +4,11 @@ import type { ComboboxCallbacks, ComboboxHandle } from './types';
4
4
  *
5
5
  * Creates a full combobox handle with the button-mode controller automatically
6
6
  * wired in and the trigger registered. The consumer only needs to call
7
- * `handle.registerListbox(listbox)`.
7
+ * `handle.list.mount(listbox)`.
8
8
  *
9
- * Handles: Space (select/open), Home/End (listbox navigation),
10
- * printable characters (typeahead), and click (toggle).
9
+ * Handles what is button-specific: click (toggle), Space (open), Tab and Alt+ArrowUp (select),
10
+ * and "open first" for Home/End, ArrowLeft/Right and typeahead. The navigation itself is
11
+ * delegated to `list.handleKeydown`.
11
12
  *
12
13
  * @param button The button element to use as the combobox trigger.
13
14
  * @param callbacks Callbacks for select and open/close events.
@@ -21,7 +21,7 @@ export interface SetupComboboxInputOptions extends ComboboxCallbacks, ComboboxIn
21
21
  *
22
22
  * Creates a full combobox handle with the input-mode controller automatically
23
23
  * wired in and the trigger registered. The consumer only needs to call
24
- * `handle.registerListbox(listbox)`.
24
+ * `handle.list.mount(listbox)`.
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,54 +1,5 @@
1
- import type { FocusNavigationController } from '../../utils/focusNavigation';
2
- /** Section visibility state tracked per registration. */
3
- export interface SectionState {
4
- hidden: boolean;
5
- 'aria-hidden': boolean;
6
- }
7
- /** Registration entry for a section element. */
8
- export interface SectionRegistration {
9
- callback: (state: SectionState) => void;
10
- last: SectionState;
11
- }
12
- /** Registration entry for an option element. */
13
- export interface OptionRegistration {
14
- callback: (isFiltered: boolean) => void;
15
- lastFiltered: boolean;
16
- }
17
- /** Event name for the active state of one option. */
18
- export type OptionActiveEvent = `optionActive:${string}`;
19
- /** Map of combobox event names to their payload types. */
20
- export interface ComboboxEventMap {
21
- /** Fired when the combobox open state changes. Payload: whether the combobox is open. */
22
- open: boolean;
23
- /** Fired when the active descendant changes (visual focus). Payload: the option id or null. */
24
- activeDescendantChange: string | null;
25
- /**
26
- * Fired when the visible option count changes.
27
- * Payload: the number of visible options plus the current input value.
28
- */
29
- optionsChange: {
30
- optionsLength: number;
31
- inputValue?: string;
32
- } | undefined;
33
- /**
34
- * Fired immediately when the aggregate loading state changes (skeleton count transitions
35
- * between 0 and >0). Used for empty suppression in ComboboxState and for aria-busy on the listbox.
36
- */
37
- loadingChange: boolean;
38
- /**
39
- * Fired after a 500ms debounce when loading persists, or immediately when loading ends.
40
- * Used to control the loading message text in the live region (ComboboxState).
41
- */
42
- loadingAnnouncement: boolean;
43
- /**
44
- * Fired only when this option becomes the active descendant (true)
45
- * or stops being the active descendant (false).
46
- * Build the key with optionActiveEvent(optionId).
47
- */
48
- [event: OptionActiveEvent]: boolean;
49
- }
50
- /** Callback provided in events subscriptions */
51
- export type SubscriptionCallback<T extends keyof ComboboxEventMap = keyof ComboboxEventMap> = (value: ComboboxEventMap[T]) => void;
1
+ import type { ListboxHandle } from '../Listbox/types';
2
+ export type { SectionState, SectionRegistration, OptionRegistration, OptionActiveEvent } from '../Listbox/types';
52
3
  /** Callbacks provided by the consumer (React/Vue) to react to combobox state changes. */
53
4
  export interface ComboboxCallbacks {
54
5
  /** Called when an option is selected (click or keyboard). */
@@ -93,91 +44,27 @@ export interface ComboboxInputOptions {
93
44
  */
94
45
  selectionMode?: 'fill' | 'keep' | 'clear';
95
46
  }
96
- /** Handle returned by `setupCombobox`. Used by framework wrappers and mode controllers. */
47
+ /**
48
+ * Handle returned by `setupCombobox`. Used by framework wrappers and mode controllers.
49
+ *
50
+ * The combobox owns the trigger. Everything else (the open state, the option registry, the filter,
51
+ * the focus navigation, the selection, the loading state and all the events) is on the
52
+ * {@link ListboxHandle} exposed as `list`: the listbox element is mounted with `list.mount(element)`.
53
+ * The combobox open state is the listbox `open` event.
54
+ */
97
55
  export interface ComboboxHandle {
98
56
  /** Register the trigger element. Returns a cleanup function. */
99
57
  registerTrigger(trigger: HTMLInputElement | HTMLButtonElement): () => void;
100
- /** Register the listbox/grid element. Returns a cleanup function. */
101
- registerListbox(listbox: HTMLElement): () => void;
102
58
  /** Tear down all listeners and state. */
103
59
  destroy(): void;
104
- /** Subscribe to a combobox event. Returns an unsubscribe function. */
105
- subscribe<K extends keyof ComboboxEventMap>(event: K, callback: SubscriptionCallback<K>): () => void;
106
- /**
107
- * Read the last dispatched value of an event synchronously, for pull-based subscribers such as
108
- * React's `useSyncExternalStore`. Returns `undefined` until the event has fired at least once.
109
- */
110
- getSnapshot<K extends keyof ComboboxEventMap>(event: K): ComboboxEventMap[K] | undefined;
111
60
  /** The current trigger element (may be null before registration). */
112
61
  readonly trigger: HTMLInputElement | HTMLButtonElement | null;
113
- /** The current listbox/grid element (may be null before registration). */
114
- readonly listbox: HTMLElement | null;
115
- /** The focus navigation controller. */
116
- readonly focusNav: FocusNavigationController | null;
117
- /** Whether the popup is open. */
62
+ /** The listbox handle (option registry, filter, focus navigation, selection, listbox events). */
63
+ readonly list: ListboxHandle;
64
+ /** Whether the popup is open (same as `list.isOpen`). */
118
65
  readonly isOpen: boolean;
119
- /** Whether multi-select mode. */
120
- readonly isMultiSelect: boolean;
121
- /** Whether any skeleton placeholders are currently registered (loading). */
122
- readonly isLoading: boolean;
123
- /** Set the open state, update ARIA, fire callback. */
66
+ /** Set the open state and update ARIA. Subscribe to `list` `open` to observe it. */
124
67
  setIsOpen(isOpen: boolean): void;
125
- /** Select an option (or null to clear), fire callback. */
126
- select(option: HTMLElement | null): void;
127
- /**
128
- * Replay the pending navigation intent stored on the focus navigation controller via
129
- * its `goTo` resolver. Called by the framework wrapper after the option children
130
- * commit (keyboard opens from the closed state defer navigation until then). No-op
131
- * when nothing is pending.
132
- */
133
- flushPendingNavigation(): void;
134
- /**
135
- * Register an option DOM element for filter notifications.
136
- * The element's textContent is used as the searchable text.
137
- * The callback is invoked immediately with the current filter state,
138
- * and again whenever the filter changes.
139
- * Returns a cleanup function that unregisters the option.
140
- */
141
- registerOption(element: HTMLElement, onFilterChange: (isFiltered: boolean) => void): () => void;
142
- /**
143
- * Set the current filter value and notify all registered options of their match state.
144
- * Options whose text does not start with the filter value are notified with isFiltered=true.
145
- * An empty filter value clears filtering (all options become visible).
146
- */
147
- setFilter(filterValue: string): void;
148
- /**
149
- * Re-evaluate the filter state of a single registered option.
150
- * Call this after the option's `data-value` or textContent has been updated
151
- * (e.g. after a framework re-render) to ensure its filtered/visible state
152
- * is consistent with the current filter value.
153
- */
154
- refilterOption(element: HTMLElement): void;
155
- /**
156
- * Register a section DOM element for state notifications.
157
- * The callback is invoked immediately with the current state, and again whenever
158
- * the state changes after a filter update or option un/registration.
159
- *
160
- * - `hidden`: true when all registered options are filtered out (keeps children mounted
161
- * but invisible to the user and screen readers).
162
- * - `aria-hidden`: true when the section has no registered options at all (skeleton-only).
163
- * The section stays visually rendered but is hidden from assistive technology —
164
- * the live region (`ComboboxState`) handles the loading announcement instead.
165
- *
166
- * At most one of `hidden` / `aria-hidden` is true at a time.
167
- *
168
- * Returns a cleanup function that unregisters the section.
169
- */
170
- registerSection(element: HTMLElement, onChange: (state: {
171
- hidden: boolean;
172
- 'aria-hidden': boolean;
173
- }) => void): () => void;
174
- /**
175
- * Register a skeleton placeholder. Increments the internal skeleton counter.
176
- * When the counter transitions from 0 to >0, fires `loadingChange` immediately
177
- * and schedules `loadingAnnouncement` after 500ms. Returns a cleanup function
178
- * that decrements the counter (and fires the reverse transitions when reaching 0).
179
- */
180
- registerSkeleton(): () => void;
181
68
  }
182
69
  /**
183
70
  * Callback invoked when the trigger is attached and the abort controller is ready.
@@ -4,11 +4,11 @@ import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../t
4
4
  * - `'listbox'`: Standard listbox with `role="listbox"` and `role="option"` items.
5
5
  * - `'grid'`: Grid mode with `role="grid"` and `role="gridcell"` items, enabling 2D keyboard navigation.
6
6
  */
7
- export type ComboboxListType = 'listbox' | 'grid';
7
+ export type ListboxListType = 'listbox' | 'grid';
8
8
  /**
9
- * Defines the props for the core ComboboxList template.
9
+ * Defines the props for the core ListboxList template.
10
10
  */
11
- export interface ComboboxListProps extends HasClassName {
11
+ export interface ListboxListProps extends HasClassName {
12
12
  /** Accessible label for the listbox (required for accessibility). */
13
13
  'aria-label'?: string;
14
14
  /**
@@ -17,7 +17,7 @@ export interface ComboboxListProps extends HasClassName {
17
17
  * Omit (or set to `undefined`) when not loading — the attribute is not rendered as `"false"`.
18
18
  */
19
19
  'aria-busy'?: boolean;
20
- /** Content (should be ComboboxOption elements). */
20
+ /** Content (should be ListboxOption elements). */
21
21
  children?: JSXElement;
22
22
  /** The ID of the listbox element. */
23
23
  id?: string;
@@ -27,7 +27,7 @@ export interface ComboboxListProps extends HasClassName {
27
27
  * The popup type. Set to "grid" when options have action buttons.
28
28
  * @default 'listbox'
29
29
  */
30
- type?: ComboboxListType;
30
+ type?: ListboxListType;
31
31
  }
32
32
  /**
33
33
  * Component display name.
@@ -38,10 +38,10 @@ export declare const COMPONENT_NAME = "ComboboxList";
38
38
  */
39
39
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
40
40
  /**
41
- * ComboboxList core template.
41
+ * ListboxList core template.
42
42
  * Renders a List with combobox-specific ARIA attributes and styling.
43
43
  *
44
44
  * @param props Component props.
45
45
  * @return JSX element.
46
46
  */
47
- export declare const ComboboxList: (props: ComboboxListProps) => import("react").JSX.Element;
47
+ export declare const ListboxList: (props: ListboxListProps) => import("react").JSX.Element;
@@ -1,18 +1,18 @@
1
1
  import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
2
  /**
3
- * Injected framework-specific components for ComboboxOption rendering.
3
+ * Injected framework-specific components for ListboxOption rendering.
4
4
  */
5
- export interface ComboboxOptionComponents {
5
+ export interface ListboxOptionComponents {
6
6
  /** Tooltip wrapper component (optional). Used when `tooltipProps` is provided. */
7
7
  Tooltip?: any;
8
8
  }
9
9
  /**
10
- * Defines the props for the core ComboboxOption template.
10
+ * Defines the props for the core ListboxOption template.
11
11
  */
12
- export interface ComboboxOptionProps extends HasClassName {
12
+ export interface ListboxOptionProps extends HasClassName {
13
13
  /** A component to be rendered before the content (e.g. an icon or avatar). */
14
14
  before?: JSXElement;
15
- /** A component to be rendered after the content (e.g. ComboboxOptionAction elements). */
15
+ /** A component to be rendered after the content (e.g. ListboxOptionAction elements). */
16
16
  after?: JSXElement;
17
17
  /** Content (option label). */
18
18
  children?: JSXElement;
@@ -50,9 +50,9 @@ export interface ComboboxOptionProps extends HasClassName {
50
50
  }
51
51
  /**
52
52
  * Props that React/Vue wrappers need to re-declare with framework-specific types.
53
- * Used by `ReactToJSX<ComboboxOptionProps, ComboboxOptionPropsToOverride>`.
53
+ * Used by `ReactToJSX<ListboxOptionProps, ListboxOptionPropsToOverride>`.
54
54
  */
55
- export type ComboboxOptionPropsToOverride = 'before' | 'after' | 'children' | 'tooltipProps' | 'actionProps';
55
+ export type ListboxOptionPropsToOverride = 'before' | 'after' | 'children' | 'tooltipProps' | 'actionProps';
56
56
  /**
57
57
  * Component display name.
58
58
  */
@@ -62,7 +62,7 @@ export declare const COMPONENT_NAME = "ComboboxOption";
62
62
  */
63
63
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
64
64
  /**
65
- * ComboboxOption core template.
65
+ * ListboxOption core template.
66
66
  * Renders a ListItem with combobox-specific ARIA attributes and structure.
67
67
  *
68
68
  * In grid mode, the ListItem renders with `role="row"` and the option content
@@ -71,4 +71,4 @@ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
71
71
  * @param props Component props.
72
72
  * @return JSX element.
73
73
  */
74
- export declare const ComboboxOption: (props: ComboboxOptionProps, { Tooltip }?: ComboboxOptionComponents) => import("react").JSX.Element;
74
+ export declare const ListboxOption: (props: ListboxOptionProps, { Tooltip }?: ListboxOptionComponents) => import("react").JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import type { CommonRef, HasClassName, HasPolymorphicAs, HasRequiredLinkHref, JSXElement, LumxClassName } from '../../types';
2
2
  import { ClickableElement } from '../RawClickable';
3
3
  /**
4
- * Defines the props for the core ComboboxOptionAction template.
4
+ * Defines the props for the core ListboxOptionAction template.
5
5
  */
6
- export type ComboboxOptionActionProps<E extends ClickableElement = 'button'> = HasPolymorphicAs<E> & HasClassName & HasRequiredLinkHref<E> & {
6
+ export type ListboxOptionActionProps<E extends ClickableElement = 'button'> = HasPolymorphicAs<E> & HasClassName & HasRequiredLinkHref<E> & {
7
7
  /** Content of the action (icon, label, etc.). */
8
8
  children?: JSXElement;
9
9
  /** Unique ID for the action element. */
@@ -24,7 +24,7 @@ export declare const COMPONENT_NAME = "ComboboxOptionAction";
24
24
  */
25
25
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
26
26
  /**
27
- * ComboboxOptionAction core template.
27
+ * ListboxOptionAction core template.
28
28
  * Renders a secondary action button within a combobox option row (grid mode).
29
29
  * Each action renders as a `role="gridcell"` element, enabling 2D keyboard
30
30
  * navigation (ArrowLeft/Right to move between the option and its actions).
@@ -32,4 +32,4 @@ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
32
32
  * @param props Component props.
33
33
  * @return JSX element.
34
34
  */
35
- export declare const ComboboxOptionAction: <E extends ClickableElement = "button">(props: ComboboxOptionActionProps<E>) => import("react").JSX.Element;
35
+ export declare const ListboxOptionAction: <E extends ClickableElement = "button">(props: ListboxOptionActionProps<E>) => import("react").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
2
  /**
3
- * Defines the props for the core ComboboxOptionMoreInfo template.
3
+ * Defines the props for the core ListboxOptionMoreInfo template.
4
4
  */
5
- export interface ComboboxOptionMoreInfoProps extends HasClassName {
5
+ export interface ListboxOptionMoreInfoProps extends HasClassName {
6
6
  /** Popover content (additional details about the option). */
7
7
  children?: JSXElement;
8
8
  /** Whether the popover is open. */
@@ -21,11 +21,11 @@ export interface ComboboxOptionMoreInfoProps extends HasClassName {
21
21
  /**
22
22
  * Props that React/Vue wrappers need to re-declare with framework-specific types.
23
23
  */
24
- export type ComboboxOptionMoreInfoPropsToOverride = 'children' | 'popoverId' | 'isOpen';
24
+ export type ListboxOptionMoreInfoPropsToOverride = 'children' | 'popoverId' | 'isOpen';
25
25
  /**
26
- * Injected framework-specific components for ComboboxOptionMoreInfo rendering.
26
+ * Injected framework-specific components for ListboxOptionMoreInfo rendering.
27
27
  */
28
- export interface ComboboxOptionMoreInfoComponents {
28
+ export interface ListboxOptionMoreInfoComponents {
29
29
  /** IconButton component (framework-specific). */
30
30
  IconButton: any;
31
31
  /** Popover component (framework-specific). */
@@ -40,7 +40,7 @@ export declare const COMPONENT_NAME = "ComboboxOptionMoreInfo";
40
40
  */
41
41
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
42
42
  /**
43
- * ComboboxOptionMoreInfo core template.
43
+ * ListboxOptionMoreInfo core template.
44
44
  * Renders an info icon button with a popover that shows additional details about a combobox option.
45
45
  * The popover opens on mouse hover or when the parent option is keyboard-highlighted.
46
46
  *
@@ -51,4 +51,4 @@ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
51
51
  * @param components Injected framework-specific components.
52
52
  * @return JSX element.
53
53
  */
54
- export declare const ComboboxOptionMoreInfo: (props: ComboboxOptionMoreInfoProps, { IconButton, Popover }: ComboboxOptionMoreInfoComponents) => import("react").JSX.Element;
54
+ export declare const ListboxOptionMoreInfo: (props: ListboxOptionMoreInfoProps, { IconButton, Popover }: ListboxOptionMoreInfoComponents) => import("react").JSX.Element;
@@ -1,13 +1,13 @@
1
1
  import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
2
  /**
3
- * Defines the props for the core ComboboxOptionSkeleton template.
3
+ * Defines the props for the core ListboxOptionSkeleton template.
4
4
  */
5
- export interface ComboboxOptionSkeletonProps extends HasClassName {
5
+ export interface ListboxOptionSkeletonProps extends HasClassName {
6
6
  /** Content rendered before the skeleton text (e.g. SkeletonCircle for avatar placeholders). */
7
7
  before?: JSXElement;
8
8
  /** Content rendered after the skeleton text. */
9
9
  after?: JSXElement;
10
- /** Show a secondary skeleton line (mirrors ComboboxOption's `description` prop). */
10
+ /** Show a secondary skeleton line (mirrors ListboxOption's `description` prop). */
11
11
  hasDescription?: boolean;
12
12
  /** Override the default SkeletonTypography content entirely. */
13
13
  children?: JSXElement;
@@ -22,9 +22,9 @@ export interface ComboboxOptionSkeletonProps extends HasClassName {
22
22
  }
23
23
  /**
24
24
  * Props that React/Vue wrappers need to re-declare with framework-specific types.
25
- * Used by `ReactToJSX<ComboboxOptionSkeletonProps, ComboboxOptionSkeletonPropsToOverride>`.
25
+ * Used by `ReactToJSX<ListboxOptionSkeletonProps, ListboxOptionSkeletonPropsToOverride>`.
26
26
  */
27
- export type ComboboxOptionSkeletonPropsToOverride = 'before' | 'after' | 'children';
27
+ export type ListboxOptionSkeletonPropsToOverride = 'before' | 'after' | 'children';
28
28
  /**
29
29
  * Component display name.
30
30
  */
@@ -34,7 +34,7 @@ export declare const COMPONENT_NAME = "ComboboxOptionSkeleton";
34
34
  */
35
35
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
36
36
  /**
37
- * ComboboxOptionSkeleton core template.
37
+ * ListboxOptionSkeleton core template.
38
38
  * Renders a skeleton placeholder `<li>` inside a combobox list, styled to match
39
39
  * option dimensions. Uses `role="none"` so screen readers ignore it.
40
40
  *
@@ -44,4 +44,4 @@ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
44
44
  * @param props Component props.
45
45
  * @return JSX element.
46
46
  */
47
- export declare const ComboboxOptionSkeleton: (props: ComboboxOptionSkeletonProps) => import("react").JSX.Element;
47
+ export declare const ListboxOptionSkeleton: (props: ListboxOptionSkeletonProps) => import("react").JSX.Element;
@@ -1,13 +1,13 @@
1
1
  import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
2
  /**
3
- * Defines the props for the core ComboboxSection template.
3
+ * Defines the props for the core ListboxSection template.
4
4
  */
5
- export interface ComboboxSectionProps extends HasClassName {
5
+ export interface ListboxSectionProps extends HasClassName {
6
6
  /** Section label displayed as the group title. Accepts a plain string or custom JSX content. */
7
7
  label?: string | JSXElement;
8
8
  /** Section icon */
9
9
  icon?: string;
10
- /** Section content (should be ComboboxOption elements). */
10
+ /** Section content (should be ListboxOption elements). */
11
11
  children: JSXElement;
12
12
  /** ref to the root element. */
13
13
  ref?: CommonRef;
@@ -20,19 +20,19 @@ export interface ComboboxSectionProps extends HasClassName {
20
20
  /**
21
21
  * When true, the section is visually rendered (label + content) but hidden from assistive
22
22
  * technology. Used for skeleton-only sections: the visual skeleton provides feedback to
23
- * sighted users, while the live region (`ComboboxState`) handles the loading announcement.
23
+ * sighted users, while the live region (`ListboxState`) handles the loading announcement.
24
24
  */
25
25
  'aria-hidden'?: boolean;
26
26
  }
27
27
  /**
28
28
  * Props that React/Vue wrappers need to re-declare with framework-specific types.
29
- * Used by `ReactToJSX<ComboboxSectionProps, ComboboxSectionPropsToOverride>`.
29
+ * Used by `ReactToJSX<ListboxSectionProps, ListboxSectionPropsToOverride>`.
30
30
  */
31
- export type ComboboxSectionPropsToOverride = 'children';
31
+ export type ListboxSectionPropsToOverride = 'children';
32
32
  /**
33
- * Injected framework-specific components for ComboboxSection rendering.
33
+ * Injected framework-specific components for ListboxSection rendering.
34
34
  */
35
- export interface ComboboxSectionComponents {
35
+ export interface ListboxSectionComponents {
36
36
  /** ListSection component (framework-specific). */
37
37
  ListSection: any;
38
38
  }
@@ -45,7 +45,7 @@ export declare const COMPONENT_NAME = "ComboboxSection";
45
45
  */
46
46
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
47
47
  /**
48
- * ComboboxSection core template.
48
+ * ListboxSection core template.
49
49
  * Renders a ListSection with combobox-specific ARIA roles.
50
50
  *
51
51
  * Framework-specific components (ListSection) are passed as a second argument
@@ -55,4 +55,4 @@ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
55
55
  * @param components Injected framework-specific components.
56
56
  * @return JSX element.
57
57
  */
58
- export declare const ComboboxSection: (props: ComboboxSectionProps, { ListSection }: ComboboxSectionComponents) => import("react").JSX.Element;
58
+ export declare const ListboxSection: (props: ListboxSectionProps, { ListSection }: ListboxSectionComponents) => import("react").JSX.Element;
@@ -9,9 +9,9 @@ export declare const COMPONENT_NAME = "ComboboxState";
9
9
  */
10
10
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
11
11
  /**
12
- * Defines the props for the core ComboboxState template.
12
+ * Defines the props for the core ListboxState template.
13
13
  */
14
- export interface ComboboxStateProps {
14
+ export interface ListboxStateProps {
15
15
  /**
16
16
  * Message to display when the list has no visible options.
17
17
  * Can be a plain string or a function receiving the current input value (for dynamic messages).
@@ -72,7 +72,7 @@ export interface ComboboxStateProps {
72
72
  /**
73
73
  * Components injected by the framework wrapper (dependency injection).
74
74
  */
75
- export interface ComboboxStateComponents {
75
+ export interface ListboxStateComponents {
76
76
  /**
77
77
  * GenericBlock component (framework-specific, e.g. React GenericBlock with FlexBox handling).
78
78
  */
@@ -83,7 +83,7 @@ export interface ComboboxStateComponents {
83
83
  Text: (props: TextProps) => any;
84
84
  }
85
85
  /**
86
- * ComboboxState core template.
86
+ * ListboxState core template.
87
87
  * Renders empty/error/option-count state messages inside the combobox popover.
88
88
  * The block itself acts as a screen reader live region (`role="status" aria-live="polite"`).
89
89
  *
@@ -96,4 +96,4 @@ export interface ComboboxStateComponents {
96
96
  * @param components Injected framework-specific components.
97
97
  * @return JSX element or null when no state is active.
98
98
  */
99
- export declare const ComboboxState: (props: ComboboxStateProps, { GenericBlock, Text }: ComboboxStateComponents) => import("react").JSX.Element;
99
+ export declare const ListboxState: (props: ListboxStateProps, { GenericBlock, Text }: ListboxStateComponents) => import("react").JSX.Element;
@@ -0,0 +1,42 @@
1
+ /** Internal listbox components namespace type. */
2
+ export interface ListboxNamespace {
3
+ /** Standalone listbox provider (creates the listbox handle). */
4
+ Provider: any;
5
+ /** List (listbox pattern by default, grid pattern with `type="grid"`). */
6
+ List: any;
7
+ Option: any;
8
+ OptionAction: any;
9
+ Section: any;
10
+ }
11
+ type RenderResult = {
12
+ unmount: () => void;
13
+ container: HTMLElement;
14
+ };
15
+ /**
16
+ * Options to set up the listbox test suite.
17
+ * Injected by the framework-specific test file (React or Vue).
18
+ */
19
+ export interface ListboxTestSetup {
20
+ components: {
21
+ Listbox: ListboxNamespace;
22
+ /** Combobox namespace (to test the listbox inside a combobox context). */
23
+ Combobox: {
24
+ Provider: any;
25
+ Button: any;
26
+ Popover: any;
27
+ List: any;
28
+ Option: any;
29
+ };
30
+ IconButton: any;
31
+ };
32
+ /**
33
+ * Render a template with controlled state management.
34
+ * Mirrors the withValueOnChange Storybook decorator.
35
+ */
36
+ renderWithState: (template: (props: any) => any, initialArgs?: Record<string, any>, options?: {
37
+ onChangeProp?: string;
38
+ valueExtract?: (v: any) => any;
39
+ }) => RenderResult;
40
+ }
41
+ export default function listboxTests({ components: { Listbox, Combobox, IconButton }, renderWithState, }: ListboxTestSetup): void;
42
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { OptionActiveEvent } from './types';
2
+ export declare const OPTION_ACTIVE_EVENT_PREFIX: "optionActive:";
3
+ export declare const optionActiveEvent: (optionId: string) => OptionActiveEvent;
4
+ export declare const isOptionActiveEvent: (event: string) => event is OptionActiveEvent;
@@ -0,0 +1,18 @@
1
+ export { setupListbox } from './setupListbox';
2
+ export type { ListboxEventMap, ListboxFocusOwnerLink, ListboxHandle, ListboxOptions, OptionActiveEvent } from './types';
3
+ export { ListboxList } from './ListboxList';
4
+ export type { ListboxListProps, ListboxListType } from './ListboxList';
5
+ export { ListboxOption } from './ListboxOption';
6
+ export type { ListboxOptionProps, ListboxOptionPropsToOverride } from './ListboxOption';
7
+ export { ListboxOptionAction } from './ListboxOptionAction';
8
+ export type { ListboxOptionActionProps } from './ListboxOptionAction';
9
+ export { ListboxOptionSkeleton } from './ListboxOptionSkeleton';
10
+ export type { ListboxOptionSkeletonProps, ListboxOptionSkeletonPropsToOverride } from './ListboxOptionSkeleton';
11
+ export { ListboxOptionMoreInfo } from './ListboxOptionMoreInfo';
12
+ export type { ListboxOptionMoreInfoProps, ListboxOptionMoreInfoPropsToOverride, ListboxOptionMoreInfoComponents, } from './ListboxOptionMoreInfo';
13
+ export { ListboxSection } from './ListboxSection';
14
+ export type { ListboxSectionProps, ListboxSectionPropsToOverride, ListboxSectionComponents } from './ListboxSection';
15
+ export { ListboxState } from './ListboxState';
16
+ export type { ListboxStateProps } from './ListboxState';
17
+ export { subscribeListboxState } from './subscribeListboxState';
18
+ export type { ListboxStateSetters } from './subscribeListboxState';
@@ -0,0 +1,40 @@
1
+ import { type FocusNavigationCallbacks, type FocusNavigationController } from '../../utils/focusNavigation';
2
+ /** Options shared by the list and grid navigation modules. */
3
+ interface NavigationOptions {
4
+ /** The mounted listbox (or grid) element. */
5
+ container: HTMLElement;
6
+ /** Focus state change callbacks (visual focus + `aria-activedescendant`). */
7
+ callbacks: FocusNavigationCallbacks;
8
+ /** Abort signal (unmount). */
9
+ signal: AbortSignal;
10
+ /** Read the active item (from the focus owner `aria-activedescendant`). */
11
+ getActiveItem: () => HTMLElement | null;
12
+ /** When true, ArrowDown/ArrowUp wrap around (list mode only). */
13
+ wrap?: boolean;
14
+ }
15
+ /**
16
+ * Navigation module of a mounted listbox: everything that differs between
17
+ * the listbox pattern (`role="listbox"`) and the grid pattern (`role="grid"`).
18
+ */
19
+ export interface ListboxNavigation {
20
+ /** Pattern of the mounted element. */
21
+ readonly type: 'listbox' | 'grid';
22
+ /** The focus navigation controller. */
23
+ readonly focusNav: FocusNavigationController;
24
+ /** Selector of the elements that can become active (options, or grid cells). */
25
+ readonly cellSelector: string;
26
+ /** Whether a clicked cell selects its option (false for grid action cells). */
27
+ isOptionCell(cell: HTMLElement): boolean;
28
+ /** Scroll the active item into view. */
29
+ scrollIntoView(item: HTMLElement): void;
30
+ /**
31
+ * Move the active cell left/right (grid only, when there is an active cell).
32
+ * Returns true when the key was handled (grid with an active cell), even at the row edge.
33
+ */
34
+ navigateHorizontal(key: 'ArrowLeft' | 'ArrowRight'): boolean;
35
+ }
36
+ /** Navigation module for the listbox pattern (1D list of `role="option"`). */
37
+ export declare function createListNavigation(options: NavigationOptions): ListboxNavigation;
38
+ /** Navigation module for the grid pattern (rows of `role="gridcell"`: option cell + action cells). */
39
+ export declare function createGridNavigation(options: NavigationOptions): ListboxNavigation;
40
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { ListboxHandle, ListboxOptions } from './types';
2
+ /**
3
+ * Set up listbox behavior (WAI-ARIA listbox or grid pattern) independent of any DOM element.
4
+ *
5
+ * The handle owns the option/section/skeleton registry, the filter state, the focus navigation
6
+ * (once an element is mounted), the selection, the loading announcement and the listbox events.
7
+ * The navigation module (listbox or grid pattern) is selected from the element role on mount.
8
+ *
9
+ * - Standalone (no `focusOwner` option): the listbox element owns DOM focus and
10
+ * `aria-activedescendant`, and handles its own keyboard navigation.
11
+ * - Linked (`focusOwner` option, e.g. a combobox trigger): the parent owns focus and the keyboard;
12
+ * the listbox writes `aria-activedescendant` on the parent focus owner.
13
+ *
14
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
15
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/grid/
16
+ */
17
+ export declare function setupListbox(options?: ListboxOptions): ListboxHandle;
@@ -0,0 +1,24 @@
1
+ import type { ListboxHandle } from '../Listbox/types';
2
+ /** Setters invoked by `subscribeListboxState` when handle events fire. */
3
+ export interface ListboxStateSetters {
4
+ /** Called immediately with the current loading state, then on every `loadingChange` event. */
5
+ setIsLoading: (value: boolean) => void;
6
+ /** Called on every `loadingAnnouncement` event (debounced 500ms after skeletons mount). */
7
+ setShouldAnnounce: (value: boolean) => void;
8
+ /** Called with `true` after a short delay when the options become visible, and `false` immediately when hidden. */
9
+ setIsOpen: (value: boolean) => void;
10
+ }
11
+ /**
12
+ * Subscribe to the listbox handle events needed by `ListboxState`.
13
+ *
14
+ * Manages three subscriptions:
15
+ * - `loadingChange` → `setIsLoading` (+ synchronous initial read of `list.isLoading`)
16
+ * - `loadingAnnouncement` → `setShouldAnnounce`
17
+ * - `open` → `setIsOpen` (deferred by {@link OPEN_ANNOUNCEMENT_DELAY}ms when shown, immediate when hidden)
18
+ * (a standalone listbox is always visible: `setIsOpen(true)` once, no subscription)
19
+ *
20
+ * @param list The listbox handle to subscribe to (`ComboboxHandle.list` inside a combobox).
21
+ * @param setters Framework-specific state setters.
22
+ * @returns A cleanup function that unsubscribes all events and clears timers.
23
+ */
24
+ export declare function subscribeListboxState(list: ListboxHandle, setters: ListboxStateSetters): () => void;
@@ -0,0 +1,146 @@
1
+ import type { FocusNavigationController } from '../../utils/focusNavigation';
2
+ /** Section visibility state tracked per registration. */
3
+ export interface SectionState {
4
+ hidden: boolean;
5
+ 'aria-hidden': boolean;
6
+ }
7
+ /** Registration entry for a section element. */
8
+ export interface SectionRegistration {
9
+ callback: (state: SectionState) => void;
10
+ last: SectionState;
11
+ }
12
+ /** Registration entry for an option element. */
13
+ export interface OptionRegistration {
14
+ callback: (isFiltered: boolean) => void;
15
+ lastFiltered: boolean;
16
+ }
17
+ /** Event name for the active state of one option. */
18
+ export type OptionActiveEvent = `optionActive:${string}`;
19
+ /** Map of listbox event names to their payload types. */
20
+ export interface ListboxEventMap {
21
+ /** Fired when the active descendant changes (visual focus). Payload: the option id or null. */
22
+ activeDescendantChange: string | null;
23
+ /**
24
+ * Fired when the visible option count changes.
25
+ * Payload: the number of visible options plus the current input value (combobox only).
26
+ */
27
+ optionsChange: {
28
+ optionsLength: number;
29
+ inputValue?: string;
30
+ } | undefined;
31
+ /**
32
+ * Fired immediately when the aggregate loading state changes (skeleton count transitions
33
+ * between 0 and >0). Used for empty suppression in ListboxState and for aria-busy on the listbox.
34
+ */
35
+ loadingChange: boolean;
36
+ /**
37
+ * Fired after a 500ms debounce when loading persists while the options are visible,
38
+ * or immediately when loading ends. Used to control the loading message text in the live region.
39
+ */
40
+ loadingAnnouncement: boolean;
41
+ /**
42
+ * Fired when the options become visible or hidden (see {@link ListboxHandle.setOpen}).
43
+ * Inside a combobox, this is the combobox open state. A standalone listbox is open from
44
+ * creation and never closes. Replayed on subscribe while open.
45
+ */
46
+ open: boolean;
47
+ /**
48
+ * Fired only when this option becomes the active descendant (true)
49
+ * or stops being the active descendant (false).
50
+ * Build the key with optionActiveEvent(optionId).
51
+ */
52
+ [event: OptionActiveEvent]: boolean;
53
+ }
54
+ /**
55
+ * Link to a parent widget that owns focus (e.g. a combobox trigger).
56
+ * Without it, the listbox is standalone and owns focus itself.
57
+ * The parent observes the listbox through its events (`optionsChange`, `loadingChange`, `open`, …).
58
+ */
59
+ export interface ListboxFocusOwnerLink {
60
+ /** The element that holds DOM focus and `aria-activedescendant`. */
61
+ getFocusOwner(): HTMLElement | null;
62
+ /** Current input value, sent in the `optionsChange` payload. */
63
+ getInputValue?(): string;
64
+ /** Called after the listbox (or grid) element is mounted (e.g. to sync `aria-haspopup` on the trigger). */
65
+ onMount?(element: HTMLElement): void;
66
+ }
67
+ /** Options of {@link setupListbox}. */
68
+ export interface ListboxOptions {
69
+ /**
70
+ * Called when an option is selected, or when the selection is cleared (see {@link ListboxHandle.select}).
71
+ * `option.value` is the selected option value (empty string when clearing).
72
+ * `element` is the selected option element (null when clearing).
73
+ */
74
+ onSelect?(option: {
75
+ value: string;
76
+ }, element: HTMLElement | null): void;
77
+ /** When true, ArrowDown/ArrowUp wrap around (list mode). Default: false. */
78
+ wrapNavigation?: boolean;
79
+ /** Parent focus owner. Omit for a standalone listbox. */
80
+ focusOwner?: ListboxFocusOwnerLink;
81
+ }
82
+ /** Handle returned by {@link setupListbox}. */
83
+ export interface ListboxHandle {
84
+ /**
85
+ * Mount the listbox (or grid) element: create the focus navigation and the delegated
86
+ * click/mousedown listeners. In standalone mode, also attach the keyboard and focus listeners.
87
+ * Returns a cleanup function that unmounts it. Mounting another element unmounts the previous one.
88
+ */
89
+ mount(element: HTMLElement): () => void;
90
+ /** Tear down all listeners and state. */
91
+ destroy(): void;
92
+ /** Subscribe to a listbox event. Returns an unsubscribe function. */
93
+ subscribe<K extends keyof ListboxEventMap>(event: K, callback: (value: ListboxEventMap[K]) => void): () => void;
94
+ /** Read the last dispatched value of an event (for pull-based subscribers). */
95
+ getSnapshot<K extends keyof ListboxEventMap>(event: K): ListboxEventMap[K] | undefined;
96
+ /** The mounted listbox/grid element. */
97
+ readonly element: HTMLElement | null;
98
+ /** Pattern of the mounted element: `'listbox'` or `'grid'` (null while not mounted). */
99
+ readonly type: 'listbox' | 'grid' | null;
100
+ /** The focus navigation controller (null while not mounted). */
101
+ readonly focusNav: FocusNavigationController | null;
102
+ /** Whether the listbox owns focus itself (no `focusOwner` link). */
103
+ readonly isStandalone: boolean;
104
+ /** Whether the options are visible (standalone: always; combobox: the open state). */
105
+ readonly isOpen: boolean;
106
+ /** Whether the listbox is in multi-select mode (`aria-multiselectable="true"`). */
107
+ readonly isMultiSelect: boolean;
108
+ /** Whether any skeleton placeholders are registered (loading). */
109
+ readonly isLoading: boolean;
110
+ /** Whether the listbox has visible options or skeletons. */
111
+ readonly hasVisibleContent: boolean;
112
+ /**
113
+ * Set whether the options are visible (standalone: always visible; combobox: open state).
114
+ * The loading announcement only fires while the options are visible.
115
+ */
116
+ setOpen(isOpen: boolean): void;
117
+ /**
118
+ * Select an option and fire `onSelect` with its value.
119
+ * With `null`, clear the selection: `onSelect` receives an empty string value and a null element.
120
+ */
121
+ select(option: HTMLElement | null): void;
122
+ /**
123
+ * Handle the listbox navigation keys: arrows, Home/End, PageUp/PageDown, Enter, Space,
124
+ * grid cells (ArrowLeft/ArrowRight) and typeahead. The only navigation implementation: a
125
+ * standalone listbox calls it from its own keydown, a combobox calls it from the trigger keydown.
126
+ * Returns true when the key was handled (Enter/Space need an active option, PageUp/PageDown too).
127
+ */
128
+ handleKeydown(event: KeyboardEvent): boolean;
129
+ /**
130
+ * Move the active cell left/right (grid pattern only, when there is an active cell).
131
+ * Returns true when the key was handled.
132
+ */
133
+ navigateHorizontal(key: 'ArrowLeft' | 'ArrowRight'): boolean;
134
+ /** Replay the pending navigation intent (see {@link FocusNavigationController.goTo}). */
135
+ flushPendingNavigation(): void;
136
+ /** Register an option element for filter notifications. Returns a cleanup function. */
137
+ registerOption(element: HTMLElement, onFilterChange: (isFiltered: boolean) => void): () => void;
138
+ /** Set the filter value and notify all registered options. */
139
+ setFilter(filterValue: string): void;
140
+ /** Re-evaluate the filter state of a single registered option. */
141
+ refilterOption(element: HTMLElement): void;
142
+ /** Register a section element for state notifications. Returns a cleanup function. */
143
+ registerSection(element: HTMLElement, onChange: (state: SectionState) => void): () => void;
144
+ /** Register a skeleton placeholder. Returns a cleanup function. */
145
+ registerSkeleton(): () => void;
146
+ }
@@ -1,13 +1,13 @@
1
1
  import type { OptionRegistration, SectionRegistration } from './types';
2
2
  /**
3
- * Get the value for a combobox option element.
3
+ * Get the value for an option element.
4
4
  * Uses `data-value` when set; falls back to the element's trimmed `textContent`.
5
5
  *
6
6
  * This is the *selection* value , which may differ from the visible label
7
7
  */
8
8
  export declare function getOptionValue(option: HTMLElement): string;
9
9
  /**
10
- * Get the visible label for a combobox option element (its trimmed `textContent`).
10
+ * Get the visible label for an option element (its trimmed `textContent`).
11
11
  *
12
12
  * Used for typeahead matching: the user types the characters they see, which is the
13
13
  * option's label — not its `data-value` (which can be an unrelated id).
@@ -65,8 +65,8 @@ export declare function setup({ component: Popover, render, decorators: { withCo
65
65
  control: {
66
66
  type: "select" | "inline-radio";
67
67
  };
68
- options: ("top" | "right" | "bottom" | "left" | "auto" | "bottom-end" | "auto-end" | "auto-start" | "top-end" | "top-start" | "right-end" | "right-start" | "bottom-start" | "left-end" | "left-start")[];
69
- mapping: Record<string, "top" | "right" | "bottom" | "left" | "auto" | "bottom-end" | "auto-end" | "auto-start" | "top-end" | "top-start" | "right-end" | "right-start" | "bottom-start" | "left-end" | "left-start"> | undefined;
68
+ options: ("top" | "right" | "bottom" | "left" | "auto" | "auto-end" | "auto-start" | "top-end" | "top-start" | "right-end" | "right-start" | "bottom-end" | "bottom-start" | "left-end" | "left-start")[];
69
+ mapping: Record<string, "top" | "right" | "bottom" | "left" | "auto" | "auto-end" | "auto-start" | "top-end" | "top-start" | "right-end" | "right-start" | "bottom-end" | "bottom-start" | "left-end" | "left-start"> | undefined;
70
70
  };
71
71
  elevation: {
72
72
  control: {
@@ -1,7 +1,7 @@
1
1
  import type { GenericProps, HasClassName, HasTheme, LumxClassName } from '../../types';
2
2
  import type { TimeOfDay } from '../../utils/time';
3
3
  import type { SelectTextFieldTranslations } from '../../utils/select/types';
4
- import type { ComboboxOptionProps } from '../Combobox/ComboboxOption';
4
+ import type { ListboxOptionProps } from '../Listbox/ListboxOption';
5
5
  /**
6
6
  * Component display name.
7
7
  */
@@ -67,14 +67,14 @@ export interface TimePickerFieldWrapperProps {
67
67
  /**
68
68
  * Callback to customize individual option props.
69
69
  * Called for each time option with the hour and minute.
70
- * Return partial `ComboboxOptionProps` to override default option rendering
70
+ * Return partial `ListboxOptionProps` to override default option rendering
71
71
  * (e.g. `before`, `after`, `children`, `tooltipProps`, `actionProps`).
72
72
  * `isDisabled` is merged with the out-of-range state using `||`.
73
73
  */
74
74
  getOptionProps?: ({ hour, minute }: {
75
75
  hour: number;
76
76
  minute: number;
77
- }) => Partial<ComboboxOptionProps>;
77
+ }) => Partial<ListboxOptionProps>;
78
78
  }
79
79
  /**
80
80
  * `SelectTextField` props managed internally by the `TimePickerField` wrappers
@@ -107,7 +107,7 @@ export interface TimePickerFieldProps extends HasTheme, HasClassName, GenericPro
107
107
  getOptionProps?: ({ hour, minute }: {
108
108
  hour: number;
109
109
  minute: number;
110
- }) => Partial<ComboboxOptionProps>;
110
+ }) => Partial<ListboxOptionProps>;
111
111
  }
112
112
  /**
113
113
  * Injected framework-specific components for TimePickerField rendering.
@@ -0,0 +1,13 @@
1
+ export interface SelectionIconProps {
2
+ /** Selection type of the select (`undefined` renders nothing). */
3
+ selectionType: 'single' | 'multiple' | undefined;
4
+ /** Whether the option is selected. */
5
+ isSelected: boolean;
6
+ }
7
+ /**
8
+ * Selection state icon of an option. The icon is always rendered after the label.
9
+ *
10
+ * - `single`: a check circle icon when selected, a blank radio icon otherwise.
11
+ * - `multiple`: a checkbox icon, marked or blank.
12
+ */
13
+ export declare const SelectionIcon: ({ selectionType, isSelected }: SelectionIconProps) => import("react").JSX.Element | null;
@@ -1,14 +1,7 @@
1
1
  import type { JSXElement } from '../../types';
2
2
  import type { BaseSelectComponents, RenderSelectOptionsProps } from './types';
3
3
  /**
4
- * Get the selection state icons of an option. The icon is always rendered after the label.
5
- *
6
- * - `single`: a check circle icon when selected, a blank radio icon otherwise.
7
- * - `multiple`: a checkbox icon, marked or blank.
8
- */
9
- export declare function getSelectionIcons(selectionType: 'single' | 'multiple' | undefined, isSelected: boolean): JSXElement | null;
10
- /**
11
- * Render options as ComboboxOption elements.
4
+ * Render options as ListboxOption elements.
12
5
  * Framework-specific components are passed as a second argument.
13
6
  */
14
7
  export declare function renderSelectOptions<O>(props: RenderSelectOptionsProps<O>, components: BaseSelectComponents): JSXElement;
package/lumx.css CHANGED
@@ -5757,6 +5757,9 @@ table {
5757
5757
  .lumx-combobox-option-skeleton:nth-child(3n+2) .lumx-skeleton-typography {
5758
5758
  width: min(55%, 170px);
5759
5759
  }
5760
+ .lumx-combobox-option__selection-icon {
5761
+ margin: auto;
5762
+ }
5760
5763
  .lumx-combobox-option .lumx-list-item__content {
5761
5764
  display: flex;
5762
5765
  flex-direction: column;
@@ -8804,6 +8807,7 @@ table {
8804
8807
  display: flex;
8805
8808
  flex-shrink: 0;
8806
8809
  justify-content: center;
8810
+ gap: 4px;
8807
8811
  width: 24px;
8808
8812
  margin-right: 8px;
8809
8813
  }
@@ -8811,6 +8815,7 @@ table {
8811
8815
  display: flex;
8812
8816
  flex-shrink: 0;
8813
8817
  justify-content: center;
8818
+ gap: 4px;
8814
8819
  margin-left: 8px;
8815
8820
  }
8816
8821
 
@@ -8828,6 +8833,7 @@ table {
8828
8833
  display: flex;
8829
8834
  flex-shrink: 0;
8830
8835
  justify-content: center;
8836
+ gap: 4px;
8831
8837
  width: 36px;
8832
8838
  margin-right: 16px;
8833
8839
  }
@@ -8835,6 +8841,7 @@ table {
8835
8841
  display: flex;
8836
8842
  flex-shrink: 0;
8837
8843
  justify-content: center;
8844
+ gap: 4px;
8838
8845
  margin-left: 16px;
8839
8846
  }
8840
8847
 
@@ -8852,6 +8859,7 @@ table {
8852
8859
  display: flex;
8853
8860
  flex-shrink: 0;
8854
8861
  justify-content: center;
8862
+ gap: 4px;
8855
8863
  width: 36px;
8856
8864
  margin-right: 16px;
8857
8865
  }
@@ -8859,6 +8867,7 @@ table {
8859
8867
  display: flex;
8860
8868
  flex-shrink: 0;
8861
8869
  justify-content: center;
8870
+ gap: 4px;
8862
8871
  margin-left: 16px;
8863
8872
  }
8864
8873
 
@@ -8875,6 +8884,7 @@ table {
8875
8884
  display: flex;
8876
8885
  flex-shrink: 0;
8877
8886
  justify-content: center;
8887
+ gap: 4px;
8878
8888
  width: 36px;
8879
8889
  margin-right: 16px;
8880
8890
  }
@@ -8882,6 +8892,7 @@ table {
8882
8892
  display: flex;
8883
8893
  flex-shrink: 0;
8884
8894
  justify-content: center;
8895
+ gap: 4px;
8885
8896
  margin-left: 16px;
8886
8897
  }
8887
8898
 
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.25.1-alpha.0",
10
+ "@lumx/icons": "^4.25.1-alpha.2",
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.25.1-alpha.0",
69
+ "version": "4.25.1-alpha.2",
70
70
  "devDependencies": {
71
71
  "@rollup/plugin-typescript": "^12.3.0",
72
72
  "@testing-library/dom": "^10.4.1",
@@ -70,6 +70,11 @@
70
70
  }
71
71
  }
72
72
 
73
+ // Selection state icon (select options), centered in the `after` slot
74
+ &__selection-icon {
75
+ margin: auto;
76
+ }
77
+
73
78
  // Center option content
74
79
  .#{$lumx-base-prefix}-list-item__content {
75
80
  display: flex;
@@ -89,6 +89,7 @@
89
89
  display: flex;
90
90
  flex-shrink: 0;
91
91
  justify-content: center;
92
+ gap: $lumx-spacing-unit-tiny;
92
93
  }
93
94
 
94
95
  @mixin lumx-list-item-before($size) {
@@ -1,23 +0,0 @@
1
- import { type FocusNavigationController } from '../../utils/focusNavigation';
2
- import type { ComboboxEventMap, ComboboxHandle } from './types';
3
- /**
4
- * Set up focus navigation and delegated event listeners on a listbox element.
5
- *
6
- * This merges two concerns:
7
- * 1. Creating the appropriate {@link FocusNavigationController} (grid or list mode)
8
- * with callbacks that manage `aria-activedescendant` and visual focus indicators.
9
- * 2. Attaching delegated `click` and `mousedown` listeners to the listbox for
10
- * option selection and blur prevention.
11
- *
12
- * The caller is responsible for guarding against duplicate calls (i.e., checking
13
- * that a focus navigation controller does not already exist before calling)
14
- * and ensuring `handle.trigger` and `handle.listbox` are non-null.
15
- *
16
- * @param handle The combobox handle (provides trigger, listbox, select, etc.).
17
- * @param signal Abort signal used to clean up all attached listeners.
18
- * @param notify Notify subscribers of combobox events.
19
- * @returns The created focus navigation controller.
20
- */
21
- export declare function setupListbox(handle: ComboboxHandle, signal: AbortSignal, notify: <K extends keyof ComboboxEventMap>(event: K, value: ComboboxEventMap[K]) => void, options?: {
22
- wrapNavigation?: boolean;
23
- }): FocusNavigationController;
@@ -1,23 +0,0 @@
1
- import type { ComboboxHandle } from './types';
2
- /** Setters invoked by `subscribeComboboxState` when handle events fire. */
3
- export interface ComboboxStateSetters {
4
- /** Called immediately with the current loading state, then on every `loadingChange` event. */
5
- setIsLoading: (value: boolean) => void;
6
- /** Called on every `loadingAnnouncement` event (debounced 500ms after skeletons mount). */
7
- setShouldAnnounce: (value: boolean) => void;
8
- /** Called with `true` after a short delay when the combobox opens, and `false` immediately on close. */
9
- setIsOpen: (value: boolean) => void;
10
- }
11
- /**
12
- * Subscribe to the combobox handle events needed by `ComboboxState`.
13
- *
14
- * Manages three subscriptions:
15
- * - `loadingChange` → `setIsLoading` (+ synchronous initial read of `handle.isLoading`)
16
- * - `loadingAnnouncement` → `setShouldAnnounce`
17
- * - `open` → `setIsOpen` (deferred by {@link OPEN_ANNOUNCEMENT_DELAY}ms on open, immediate on close)
18
- *
19
- * @param handle The combobox handle to subscribe to.
20
- * @param setters Framework-specific state setters.
21
- * @returns A cleanup function that unsubscribes all events and clears timers.
22
- */
23
- export declare function subscribeComboboxState(handle: ComboboxHandle, setters: ComboboxStateSetters): () => void;