@lumx/core 4.27.0 → 4.27.1-alpha.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.
Files changed (28) hide show
  1. package/components-and-utils.css +13 -9
  2. package/js/components/Combobox/types.d.ts +0 -1
  3. package/js/components/Composite/CompositeItemDescription.d.ts +17 -0
  4. package/js/components/Composite/CompositeSelectionIcon.d.ts +20 -0
  5. package/js/components/{Listbox/ListboxState.d.ts → Composite/CompositeStatus.d.ts} +21 -25
  6. package/js/components/{Listbox → Composite}/constants.d.ts +3 -1
  7. package/js/components/Composite/index.d.ts +7 -0
  8. package/js/components/Composite/setupComposite.d.ts +28 -0
  9. package/js/components/Composite/types.d.ts +226 -0
  10. package/js/components/Composite/utils.d.ts +17 -0
  11. package/js/components/List/ListItem.d.ts +8 -1
  12. package/js/components/List/index.d.ts +8 -1
  13. package/js/components/Listbox/ListboxSection.d.ts +1 -1
  14. package/js/components/Listbox/index.d.ts +2 -3
  15. package/js/components/Listbox/navigation.d.ts +3 -38
  16. package/js/components/Listbox/setupListbox.d.ts +6 -4
  17. package/js/components/Listbox/subscribeListboxState.d.ts +4 -4
  18. package/js/components/Listbox/types.d.ts +6 -122
  19. package/js/components/Listbox/utils.d.ts +4 -28
  20. package/lumx.css +13 -9
  21. package/package.json +5 -4
  22. package/scss/_components_classes.scss +1 -0
  23. package/scss/components/combobox/_index.scss +6 -6
  24. package/scss/components/composite/_index.scss +20 -0
  25. package/scss/components/list-box/_index.scss +4 -19
  26. package/scss/core/action-area/_index.scss +3 -4
  27. package/scss/core/action-area/_mixins.scss +11 -0
  28. package/js/components/Listbox/ListboxOptionSelectionIcon.d.ts +0 -13
@@ -5040,7 +5040,7 @@ table {
5040
5040
  .lumx-combobox-popover__scroll {
5041
5041
  overflow-y: auto;
5042
5042
  }
5043
- .lumx-combobox-popover:empty, .lumx-combobox-popover:not(:has(.lumx-listbox-option)):not(:has(.lumx-listbox-state)):not(:has(.lumx-listbox-option-skeleton)) {
5043
+ .lumx-combobox-popover:not(:has(:is([role=listbox], [role=grid]):not([hidden]), .lumx-composite-status)) {
5044
5044
  display: none;
5045
5045
  }
5046
5046
 
@@ -5232,6 +5232,17 @@ table {
5232
5232
  margin-left: 52px;
5233
5233
  }
5234
5234
 
5235
+ /* ==========================================================================
5236
+ Composite
5237
+ ========================================================================== */
5238
+ .lumx-composite-status {
5239
+ text-align: center;
5240
+ }
5241
+
5242
+ .lumx-composite-item__selection-icon {
5243
+ margin: auto;
5244
+ }
5245
+
5235
5246
  /* ==========================================================================
5236
5247
  Date picker
5237
5248
  ========================================================================== */
@@ -7416,14 +7427,10 @@ table {
7416
7427
  /* ==========================================================================
7417
7428
  Listbox
7418
7429
  ========================================================================== */
7419
- .lumx-listbox-list:empty, .lumx-listbox-list:not(:has(.lumx-listbox-option)):not(:has(.lumx-listbox-state)):not(:has(.lumx-listbox-option-skeleton)) {
7430
+ .lumx-listbox-list:empty {
7420
7431
  display: none;
7421
7432
  }
7422
7433
 
7423
- .lumx-listbox-state {
7424
- text-align: center;
7425
- }
7426
-
7427
7434
  .lumx-listbox-option-skeleton .lumx-skeleton-typography {
7428
7435
  width: min(65%, 200px);
7429
7436
  }
@@ -7433,9 +7440,6 @@ table {
7433
7440
  .lumx-listbox-option-skeleton:nth-child(3n+2) .lumx-skeleton-typography {
7434
7441
  width: min(55%, 170px);
7435
7442
  }
7436
- .lumx-listbox-option__selection-icon {
7437
- margin: auto;
7438
- }
7439
7443
  .lumx-listbox-option .lumx-list-item__wrapper,
7440
7444
  .lumx-listbox-option .lumx-list-item__content {
7441
7445
  min-width: 0;
@@ -1,5 +1,4 @@
1
1
  import type { ListboxHandle } from '../Listbox/types';
2
- export type { SectionState, SectionRegistration, OptionRegistration, OptionActiveEvent } from '../Listbox/types';
3
2
  /** Callbacks provided by the consumer (React/Vue) to react to combobox state changes. */
4
3
  export interface ComboboxCallbacks {
5
4
  /** Called when an option is selected (click or keyboard). */
@@ -0,0 +1,17 @@
1
+ import type { HasClassName, JSXElement } from '../../types';
2
+ /** Props of the {@link CompositeItemDescription} template. */
3
+ export interface CompositeItemDescriptionProps extends HasClassName {
4
+ /** ID of the description (the item action refers to it with `aria-describedby`). */
5
+ id?: string;
6
+ /** The description text. */
7
+ children?: JSXElement;
8
+ /** Extra attributes (e.g. the filter match text marker of a tree item). */
9
+ [attribute: `data-${string}`]: string;
10
+ }
11
+ /**
12
+ * Helper description of a composite item (an option or a tree item), rendered after the item action.
13
+ *
14
+ * @param props Component props.
15
+ * @return JSX element.
16
+ */
17
+ export declare const CompositeItemDescription: ({ id, className, children, ...attributes }: CompositeItemDescriptionProps) => import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import type { HasClassName } from '../../types';
2
+ /**
3
+ * Component default class name.
4
+ */
5
+ export declare const CLASSNAME: "lumx-composite-item__selection-icon";
6
+ /** Class names of the previous versions on a listbox option, kept for compatibility (set by the option icon). */
7
+ export declare const LEGACY_OPTION_CLASSNAME = "lumx-listbox-option__selection-icon lumx-combobox-option__selection-icon";
8
+ export interface CompositeSelectionIconProps extends HasClassName {
9
+ /** Selection type of the select (`undefined` renders nothing). */
10
+ selectionType: 'single' | 'multiple' | undefined;
11
+ /** Whether the item is selected. */
12
+ isSelected: boolean;
13
+ }
14
+ /**
15
+ * Selection state icon of a composite item (an option or a tree item). The icon is always rendered after the label.
16
+ *
17
+ * - `single`: a check circle icon when selected, a blank radio icon otherwise.
18
+ * - `multiple`: a checkbox icon, marked or blank.
19
+ */
20
+ export declare const CompositeSelectionIcon: ({ selectionType, isSelected, className }: CompositeSelectionIconProps) => import("react").JSX.Element | null;
@@ -1,35 +1,30 @@
1
1
  import type { LumxClassName } from '../../types';
2
- import type { TextProps } from '../Text';
3
2
  /**
4
3
  * Component display name.
5
4
  */
6
- export declare const COMPONENT_NAME = "ListboxState";
5
+ export declare const COMPONENT_NAME = "CompositeStatus";
7
6
  /**
8
7
  * Component default class name and class prefix.
9
8
  */
10
9
  export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
10
+ /** Class names of the previous versions (`Combobox.State` was the listbox state), kept for compatibility. */
11
+ export declare const LEGACY_CLASSNAME = "lumx-listbox-state lumx-combobox-state";
11
12
  /**
12
- * Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
13
- *
14
- * @deprecated Use `CLASSNAME` (`lumx-listbox-*`). The legacy `lumx-combobox-*` class will be removed in the next major version.
15
- */
16
- export declare const LEGACY_CLASSNAME = "lumx-combobox-state";
17
- /**
18
- * Defines the props for the core ListboxState template.
13
+ * Defines the props for the core CompositeStatus template.
19
14
  */
20
- export interface ListboxStateProps {
15
+ export interface CompositeStatusProps {
21
16
  /**
22
- * Message to display when the list has no visible options.
17
+ * Message to display when the composite has no visible items.
23
18
  * Can be a plain string or a function receiving the current input value (for dynamic messages).
24
19
  * When omitted, the empty state is not shown.
25
20
  */
26
21
  emptyMessage?: string | ((inputValue: string) => string);
27
22
  /**
28
- * Message callback to display the number of available options.
29
- * Called with the current visible option count and should return a human-readable string
23
+ * Message callback to display the number of available items.
24
+ * Called with the current visible item count and should return a human-readable string
30
25
  * (e.g. `(n) => \`${n} result(s) available\``).
31
- * Displayed when the combobox is open, not empty, not loading, and not in error.
32
- * When omitted, no option count message is shown.
26
+ * Displayed when the composite is open, not empty, not loading, and not in error.
27
+ * When omitted, no item count message is shown.
33
28
  */
34
29
  nbOptionMessage?: (optionsLength: number) => string;
35
30
  /**
@@ -49,12 +44,12 @@ export interface ListboxStateProps {
49
44
  */
50
45
  loadingMessage?: string;
51
46
  /**
52
- * List state
47
+ * Composite state
53
48
  */
54
49
  state?: {
55
50
  /**
56
- * The number of currently visible options.
57
- * Driven by the framework wrapper via the combobox handle's `optionsChange` event.
51
+ * The number of currently visible items.
52
+ * Driven by the framework wrapper via the composite handle's `optionsChange` event.
58
53
  */
59
54
  optionsLength?: number;
60
55
  /**
@@ -78,7 +73,7 @@ export interface ListboxStateProps {
78
73
  /**
79
74
  * Components injected by the framework wrapper (dependency injection).
80
75
  */
81
- export interface ListboxStateComponents {
76
+ export interface CompositeStatusComponents {
82
77
  /**
83
78
  * GenericBlock component (framework-specific, e.g. React GenericBlock with FlexBox handling).
84
79
  */
@@ -86,20 +81,21 @@ export interface ListboxStateComponents {
86
81
  /**
87
82
  * Text component (framework-specific, e.g. React Text or Vue Text).
88
83
  */
89
- Text: (props: TextProps) => any;
84
+ Text: any;
90
85
  }
91
86
  /**
92
- * ListboxState core template.
93
- * Renders empty/error/option-count state messages inside the combobox popover.
87
+ * CompositeStatus core template: the live region of a composite (listbox, grid or tree).
88
+ * Renders the empty, loading, error and item count messages (e.g. in the combobox popover).
94
89
  * The block itself acts as a screen reader live region (`role="status" aria-live="polite"`).
95
90
  *
96
91
  * Activation rules:
97
92
  * - Error state: active when `errorMessage` is provided (presence-based).
98
- * - Empty state: active when `optionsLength` is 0 and `emptyMessage` is provided, and there is no error.
99
- * - Option count: active when `nbOptionMessage` is provided, the list is not empty, not loading, and not in error.
93
+ * - Empty state: active when the item count (`optionsLength`) is 0 and `emptyMessage` is provided, and there is
94
+ * no error.
95
+ * - Item count: active when `nbOptionMessage` is provided, the composite is not empty, not loading, and not in error.
100
96
  *
101
97
  * @param props Component props.
102
98
  * @param components Injected framework-specific components.
103
99
  * @return JSX element or null when no state is active.
104
100
  */
105
- export declare const ListboxState: (props: ListboxStateProps, { GenericBlock, Text }: ListboxStateComponents) => import("react").JSX.Element;
101
+ export declare const CompositeStatus: (props: CompositeStatusProps, { GenericBlock, Text }: CompositeStatusComponents) => import("react").JSX.Element;
@@ -1,4 +1,6 @@
1
1
  import type { OptionActiveEvent } from './types';
2
- export declare const OPTION_ACTIVE_EVENT_PREFIX: "optionActive:";
2
+ /** The active state event of one item (see {@link OptionActiveEvent}). */
3
3
  export declare const optionActiveEvent: (optionId: string) => OptionActiveEvent;
4
4
  export declare const isOptionActiveEvent: (event: string) => event is OptionActiveEvent;
5
+ /** The item id of an active state event. */
6
+ export declare const getOptionActiveId: (event: OptionActiveEvent) => string;
@@ -0,0 +1,7 @@
1
+ export { setupComposite } from './setupComposite';
2
+ export type { CompositeSetup } from './setupComposite';
3
+ export { CompositeSelectionIcon } from './CompositeSelectionIcon';
4
+ export type { CompositeSelectionIconProps } from './CompositeSelectionIcon';
5
+ export { CompositeStatus } from './CompositeStatus';
6
+ export type { CompositeStatusProps, CompositeStatusComponents } from './CompositeStatus';
7
+ export type { CompositeEventMap, CompositeEventSource, CompositeFilterMode, CompositeFocusOwnerLink, CompositeHandle, CompositeNavigation, CompositeNavigationOptions, CompositeOptions, CompositeSpecialization, CompositeType, OptionActiveEvent, } from './types';
@@ -0,0 +1,28 @@
1
+ import type { CompositeFilter, CompositeHandle, CompositeOptions, CompositeSpecialization } from './types';
2
+ /** Result of {@link setupComposite}: the handle, and the hooks the specialization calls. */
3
+ export interface CompositeSetup {
4
+ /** The composite handle (the specialization adds its own methods to it). */
5
+ handle: CompositeHandle;
6
+ /**
7
+ * Fire `optionsChange` when the visible count (or the hidden count state) changed, or when the
8
+ * input value changed while empty. The specialization calls it when its items change.
9
+ */
10
+ notifyOptionsChange(): void;
11
+ /** The current filter (set with {@link CompositeHandle.setFilter}, reset on destroy). */
12
+ getFilter(): CompositeFilter;
13
+ }
14
+ /**
15
+ * Set up the behavior shared by the composite widgets (one active item among many: WAI-ARIA listbox,
16
+ * grid, …) independent of any DOM element.
17
+ *
18
+ * The composite owns the focus owner link, the focus navigation (once an element is mounted, with the
19
+ * navigation module of the specialization), the keyboard handling, the selection, the open state, the
20
+ * filter, the skeleton registry, the loading announcement and the events. The specialization owns its item
21
+ * registry, how it applies the filter and its navigation modules (see {@link CompositeSpecialization}).
22
+ *
23
+ * - Standalone (no `focusOwner` option): the composite element owns DOM focus and
24
+ * `aria-activedescendant`, and handles its own keyboard navigation.
25
+ * - Linked (`focusOwner` option, e.g. a combobox trigger): the parent owns focus and the keyboard;
26
+ * the composite writes `aria-activedescendant` on the parent focus owner.
27
+ */
28
+ export declare function setupComposite(options: CompositeOptions, specialization: CompositeSpecialization): CompositeSetup;
@@ -0,0 +1,226 @@
1
+ import type { FocusNavigationCallbacks, FocusNavigationController } from '../../utils/focusNavigation';
2
+ /**
3
+ * Pattern of a mounted composite element (from its role, e.g. `'listbox'` or `'grid'`): each composite
4
+ * specialization (see {@link setupComposite}) defines its own patterns.
5
+ */
6
+ export type CompositeType = string;
7
+ /** Mode of the filter (see {@link CompositeHandle.setFilter}). */
8
+ export type CompositeFilterMode = 'auto' | 'manual';
9
+ /** The current filter of a composite (see {@link CompositeHandle.setFilter}). */
10
+ export interface CompositeFilter {
11
+ /** Filter value (empty string: no filter). */
12
+ value: string;
13
+ /** Filter mode (`'manual'`: the consumer renders the result, the specialization hides nothing). */
14
+ mode: CompositeFilterMode;
15
+ }
16
+ /** Event name for the active state of one item. */
17
+ export type OptionActiveEvent = `optionActive:${string}`;
18
+ /** Map of composite event names to their payload types. */
19
+ export interface CompositeEventMap {
20
+ /** Fired when the active descendant changes (visual focus). Payload: the active item id or null. */
21
+ activeDescendantChange: string | null;
22
+ /**
23
+ * Fired when the visible item count changes.
24
+ * Payload: the number of visible items plus the current input value (combobox only), and whether
25
+ * the item count must not be announced (set by the composite specialization).
26
+ */
27
+ optionsChange: {
28
+ optionsLength: number;
29
+ inputValue?: string;
30
+ isCountHidden?: boolean;
31
+ } | undefined;
32
+ /**
33
+ * Fired immediately when the aggregate loading state changes (root skeleton count transitions
34
+ * between 0 and >0). Used for empty suppression in the status and for `aria-busy` on the list.
35
+ */
36
+ loadingChange: boolean;
37
+ /**
38
+ * Fired after a 500ms debounce when loading persists while the items are visible,
39
+ * or immediately when loading ends. Used to control the loading message text in the live region.
40
+ */
41
+ loadingAnnouncement: boolean;
42
+ /**
43
+ * Fired when the items become visible or hidden (see {@link CompositeHandle.setOpen}).
44
+ * Inside a combobox, this is the combobox open state. A standalone composite is open from
45
+ * creation and never closes.
46
+ */
47
+ open: boolean;
48
+ /**
49
+ * Fired only when this item becomes the active descendant (true)
50
+ * or stops being the active descendant (false).
51
+ * Build the key with optionActiveEvent(itemId).
52
+ */
53
+ [event: OptionActiveEvent]: boolean;
54
+ }
55
+ /**
56
+ * Link to a parent widget that owns focus (e.g. a combobox trigger).
57
+ * Without it, the composite is standalone and owns focus itself.
58
+ * The parent sets the open state ({@link CompositeHandle.setOpen}) and observes the composite through its
59
+ * events (e.g. `optionsChange`).
60
+ */
61
+ export interface CompositeFocusOwnerLink {
62
+ /** The element that holds DOM focus and `aria-activedescendant`. */
63
+ getFocusOwner(): HTMLElement | null;
64
+ /** Current input value, sent in the `optionsChange` payload. */
65
+ getInputValue?(): string;
66
+ /** Called after the composite element is mounted (e.g. to sync `aria-haspopup` on the trigger). */
67
+ onMount?(element: HTMLElement): void;
68
+ }
69
+ /** Options of {@link setupComposite} (and of its specializations). */
70
+ export interface CompositeOptions {
71
+ /**
72
+ * Called when an item is selected, or when the selection is cleared (see {@link CompositeHandle.select}).
73
+ * `option.value` is the selected item value (empty string when clearing).
74
+ * `element` is the selected item element (null when clearing).
75
+ */
76
+ onSelect?(option: {
77
+ value: string;
78
+ }, element: HTMLElement | null): void;
79
+ /** When true, ArrowDown/ArrowUp wrap around (list mode). Default: false. */
80
+ wrapNavigation?: boolean;
81
+ /** Parent focus owner. Omit for a standalone composite. */
82
+ focusOwner?: CompositeFocusOwnerLink;
83
+ }
84
+ /** Options given to the navigation module of a composite specialization on mount. */
85
+ export interface CompositeNavigationOptions {
86
+ /** The mounted composite element (the navigation module is selected from its role). */
87
+ container: HTMLElement;
88
+ /** Focus state change callbacks (visual focus + `aria-activedescendant`). */
89
+ callbacks: FocusNavigationCallbacks;
90
+ /** Abort signal (unmount). */
91
+ signal: AbortSignal;
92
+ /** Read the active item (from the focus owner `aria-activedescendant`). */
93
+ getActiveItem: () => HTMLElement | null;
94
+ /** When true, ArrowDown/ArrowUp wrap around (list mode only). */
95
+ wrap?: boolean;
96
+ }
97
+ /**
98
+ * Navigation module of a mounted composite: everything that differs between the patterns
99
+ * (listbox, grid, …). Created by the composite specialization from the mounted element.
100
+ */
101
+ export interface CompositeNavigation {
102
+ /** Pattern of the mounted element. */
103
+ readonly type: CompositeType;
104
+ /** The focus navigation controller. */
105
+ readonly focusNav: FocusNavigationController;
106
+ /** Selector of the elements that can become active (options, grid cells, …). */
107
+ readonly cellSelector: string;
108
+ /** Whether a clicked cell selects its item (e.g. false for grid action cells). */
109
+ isOptionCell(cell: HTMLElement): boolean;
110
+ /** Scroll the active item into view. */
111
+ scrollIntoView(item: HTMLElement): void;
112
+ /**
113
+ * Handle ArrowLeft/ArrowRight on the active item (when the pattern has a horizontal navigation: e.g. move
114
+ * between the grid cells, open or close a tree item). Returns true when the key was handled (an active item
115
+ * exists and the pattern handles the key), even when nothing changed. Without an active item, the key is
116
+ * not handled: a standalone composite consumes it anyway, a combobox input moves its caret
117
+ * (see {@link CompositeHandle.handleKeydown}).
118
+ */
119
+ navigateHorizontal(key: 'ArrowLeft' | 'ArrowRight'): boolean;
120
+ }
121
+ /**
122
+ * What a composite specialization (listbox, …) gives to {@link setupComposite}:
123
+ * its navigation modules, its item count and its filter.
124
+ */
125
+ export interface CompositeSpecialization {
126
+ /** Create the navigation module of the mounted element (`options.container`, selected from its role). */
127
+ createNavigation(options: CompositeNavigationOptions): CompositeNavigation;
128
+ /** Number of visible items with the current filter (`optionsChange` payload and `hasVisibleContent`). */
129
+ getVisibleCount(filter: CompositeFilter): number;
130
+ /** Whether the item count must not be announced with the current filter (`optionsChange` payload). Default: false. */
131
+ isCountHidden?(filter: CompositeFilter): boolean;
132
+ /**
133
+ * Apply the new filter (see {@link CompositeHandle.setFilter}). The composite stores it (see
134
+ * {@link CompositeSetup.getFilter}), and fires `optionsChange` after it when the visible count changed.
135
+ */
136
+ applyFilter(filter: CompositeFilter): void;
137
+ /** Called after the element is mounted, to attach the specialization listeners (removed on `signal` abort). */
138
+ onMount?(element: HTMLElement, signal: AbortSignal): void;
139
+ /** Clear the specialization state (see {@link CompositeHandle.destroy}). */
140
+ destroy?(): void;
141
+ }
142
+ /** Read-only event source of a composite handle (`subscribe` + `getSnapshot`). */
143
+ export interface CompositeEventSource<M = CompositeEventMap> {
144
+ /** Subscribe to an event. Returns an unsubscribe function. */
145
+ subscribe<K extends keyof M>(event: K, callback: (value: M[K]) => void): () => void;
146
+ /** Read the last dispatched value of an event (for pull-based subscribers). */
147
+ getSnapshot<K extends keyof M>(event: K): M[K] | undefined;
148
+ }
149
+ /**
150
+ * Handle returned by {@link setupComposite}: the behavior shared by the composite widgets
151
+ * (one active item among many: listbox, grid, …).
152
+ */
153
+ export interface CompositeHandle extends CompositeEventSource {
154
+ /**
155
+ * Mount the composite element: create the focus navigation and the delegated click/mousedown
156
+ * listeners. In standalone mode, also attach the keyboard and focus listeners.
157
+ * Returns a cleanup function that unmounts it. Mounting another element unmounts the previous one.
158
+ */
159
+ mount(element: HTMLElement): () => void;
160
+ /** Tear down all listeners and state. */
161
+ destroy(): void;
162
+ /** The mounted composite element. */
163
+ readonly element: HTMLElement | null;
164
+ /** Pattern of the mounted element (null while not mounted). */
165
+ readonly type: CompositeType | null;
166
+ /** The active item (null while there is none, or while not mounted). */
167
+ readonly activeItem: HTMLElement | null;
168
+ /** Whether the composite owns focus itself (no `focusOwner` link). */
169
+ readonly isStandalone: boolean;
170
+ /** Whether the items are visible (standalone: always; combobox: the open state). */
171
+ readonly isOpen: boolean;
172
+ /** Whether the composite is in multi-select mode (`aria-multiselectable="true"`). */
173
+ readonly isMultiSelect: boolean;
174
+ /**
175
+ * Whether the composite has visible items or root skeletons. Without them, the mounted element gets
176
+ * `hidden` (unless it holds a status: the live region, e.g. a `Combobox.State` inside the list).
177
+ */
178
+ readonly hasVisibleContent: boolean;
179
+ /**
180
+ * Set whether the items are visible (standalone: always visible; combobox: open state).
181
+ * The loading announcement only fires while the items are visible.
182
+ */
183
+ setOpen(isOpen: boolean): void;
184
+ /**
185
+ * Select an item and fire `onSelect` with its value.
186
+ * With `null`, clear the selection: `onSelect` receives an empty string value and a null element.
187
+ */
188
+ select(option: HTMLElement | null): void;
189
+ /**
190
+ * Handle the navigation keys: arrows, Home/End, PageUp/PageDown, Enter, Space,
191
+ * ArrowLeft/ArrowRight (delegated to the navigation module) and typeahead. The only navigation
192
+ * implementation: a standalone composite calls it from its own keydown, a combobox calls it from
193
+ * the trigger keydown.
194
+ * Returns true when the key was handled: ArrowDown/ArrowUp/Home/End always; Enter/Space and
195
+ * PageUp/PageDown with an active item; ArrowLeft/ArrowRight always in a standalone composite, and in a
196
+ * linked one only when the navigation module handled them.
197
+ */
198
+ handleKeydown(event: KeyboardEvent): boolean;
199
+ /** Replay the pending navigation intent (see {@link activateDefaultItem}). */
200
+ flushPendingNavigation(): void;
201
+ /** Clear the active item and discard the pending navigation intent. No-op while not mounted. */
202
+ clearActiveItem(): void;
203
+ /** Make an item active. No-op while not mounted. */
204
+ setActiveItem(item: HTMLElement): void;
205
+ /**
206
+ * Make the first selected item active, or else the first (`'first'`) or the last (`'last'`) item.
207
+ * When no item can become active yet (e.g. the combobox popup is opening and its items are not
208
+ * rendered), keep the intent until {@link flushPendingNavigation}. No-op while not mounted.
209
+ */
210
+ activateDefaultItem(edge: 'first' | 'last'): void;
211
+ /**
212
+ * Set the filter value. The specialization applies it:
213
+ * - `'auto'` (default): hide the items that do not match.
214
+ * - `'manual'`: the consumer renders the result (the specialization hides nothing).
215
+ */
216
+ setFilter(filterValue: string, mode?: CompositeFilterMode): void;
217
+ /**
218
+ * Register a skeleton placeholder. Returns a cleanup function (a second call does nothing).
219
+ * A root skeleton makes the composite busy (`loadingChange`). A nested skeleton
220
+ * (`isNested`, inside a nested level of items) does not make it busy, but it starts the loading
221
+ * announcement.
222
+ */
223
+ registerSkeleton(options?: {
224
+ isNested?: boolean;
225
+ }): () => void;
226
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Get the visible label for an item element (its trimmed `textContent`).
3
+ *
4
+ * Used for typeahead matching: the user types the characters they see, which is the
5
+ * item's label — not its `data-value` (which can be an unrelated id).
6
+ */
7
+ export declare function getOptionLabel(option: HTMLElement): string;
8
+ /**
9
+ * Get the value for an item element.
10
+ * Uses `data-value` when set; falls back to the item label (see {@link getOptionLabel}).
11
+ *
12
+ * This is the *selection* value, which may differ from the visible label.
13
+ */
14
+ export declare function getOptionValue(option: HTMLElement): string;
15
+ /** Returns true when an item carries aria-disabled="true". */
16
+ export declare function isOptionDisabled(option: HTMLElement): boolean;
17
+ export declare const isSelected: (el: Element) => boolean;
@@ -31,6 +31,13 @@ export interface ListItemProps extends HasClassName, HasAriaDisabled {
31
31
  /** On click callback. */
32
32
  handleClick?: (event: any) => void;
33
33
  }
34
+ /**
35
+ * Core-only props of the ListItem template (not exposed by the React and Vue components).
36
+ */
37
+ export interface ListItemCoreProps {
38
+ /** Root element tag. Default: `li` (e.g. `div` for an item row that is not a direct list child). */
39
+ as?: 'li' | 'div';
40
+ }
34
41
  export type ListItemPropsToOverride = 'after' | 'before' | 'children' | 'handleClick';
35
42
  /**
36
43
  * Component display name.
@@ -51,7 +58,7 @@ export declare const DEFAULT_PROPS: Partial<ListItemProps>;
51
58
  * @return JSX element.
52
59
  */
53
60
  export declare const ListItem: {
54
- (props: ListItemProps): import("react").JSX.Element;
61
+ (props: ListItemProps & ListItemCoreProps): import("react").JSX.Element;
55
62
  displayName: string;
56
63
  className: "lumx-list-item";
57
64
  defaultProps: Partial<ListItemProps>;
@@ -13,6 +13,13 @@ export interface ListProps extends HasClassName {
13
13
  /** ref to the root element */
14
14
  ref?: CommonRef;
15
15
  }
16
+ /**
17
+ * Core-only props of the List template (not exposed by the React and Vue components).
18
+ */
19
+ export interface ListCoreProps {
20
+ /** Root element tag. Default: `ul`. */
21
+ as?: 'ul' | 'ol' | 'div';
22
+ }
16
23
  /**
17
24
  * Component display name.
18
25
  */
@@ -32,7 +39,7 @@ export declare const DEFAULT_PROPS: Partial<ListProps>;
32
39
  * @return JSX element.
33
40
  */
34
41
  export declare const List: {
35
- (props: ListProps): import("react").JSX.Element;
42
+ (props: ListProps & ListCoreProps): import("react").JSX.Element;
36
43
  displayName: string;
37
44
  className: "lumx-list";
38
45
  defaultProps: Partial<ListProps>;
@@ -20,7 +20,7 @@ export interface ListboxSectionProps 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 (`ListboxState`) handles the loading announcement.
23
+ * sighted users, while the live region (`CompositeStatus`) handles the loading announcement.
24
24
  */
25
25
  'aria-hidden'?: boolean;
26
26
  }
@@ -1,5 +1,6 @@
1
1
  export { setupListbox } from './setupListbox';
2
- export type { ListboxEventMap, ListboxFocusOwnerLink, ListboxHandle, ListboxOptions, OptionActiveEvent } from './types';
2
+ export type { ListboxHandle, ListboxType } from './types';
3
+ export { isListboxHandle } from './utils';
3
4
  export { ListboxList } from './ListboxList';
4
5
  export type { ListboxListProps, ListboxListType } from './ListboxList';
5
6
  export { ListboxOption } from './ListboxOption';
@@ -12,7 +13,5 @@ export { ListboxOptionMoreInfo } from './ListboxOptionMoreInfo';
12
13
  export type { ListboxOptionMoreInfoProps, ListboxOptionMoreInfoPropsToOverride, ListboxOptionMoreInfoComponents, } from './ListboxOptionMoreInfo';
13
14
  export { ListboxSection } from './ListboxSection';
14
15
  export type { ListboxSectionProps, ListboxSectionPropsToOverride, ListboxSectionComponents } from './ListboxSection';
15
- export { ListboxState } from './ListboxState';
16
- export type { ListboxStateProps } from './ListboxState';
17
16
  export { subscribeListboxState } from './subscribeListboxState';
18
17
  export type { ListboxStateSetters } from './subscribeListboxState';
@@ -1,40 +1,5 @@
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
- }
1
+ import type { CompositeNavigation, CompositeNavigationOptions } from '../Composite/types';
36
2
  /** Navigation module for the listbox pattern (1D list of `role="option"`). */
37
- export declare function createListNavigation(options: NavigationOptions): ListboxNavigation;
3
+ export declare function createListNavigation(options: CompositeNavigationOptions): CompositeNavigation;
38
4
  /** Navigation module for the grid pattern (rows of `role="gridcell"`: option cell + action cells). */
39
- export declare function createGridNavigation(options: NavigationOptions): ListboxNavigation;
40
- export {};
5
+ export declare function createGridNavigation(options: CompositeNavigationOptions): CompositeNavigation;
@@ -1,9 +1,11 @@
1
- import type { ListboxHandle, ListboxOptions } from './types';
1
+ import type { CompositeOptions } from '../Composite/types';
2
+ import type { ListboxHandle } from './types';
2
3
  /**
3
4
  * Set up listbox behavior (WAI-ARIA listbox or grid pattern) independent of any DOM element.
4
5
  *
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.
6
+ * Built on the composite base (see {@link setupComposite}: focus owner, focus navigation, keyboard,
7
+ * selection, open state, skeletons, loading announcement and events). The listbox adds the
8
+ * option/section registry, the option filter and the list and grid navigation modules.
7
9
  * The navigation module (listbox or grid pattern) is selected from the element role on mount.
8
10
  *
9
11
  * - Standalone (no `focusOwner` option): the listbox element owns DOM focus and
@@ -14,4 +16,4 @@ import type { ListboxHandle, ListboxOptions } from './types';
14
16
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/listbox/
15
17
  * @see https://www.w3.org/WAI/ARIA/apg/patterns/grid/
16
18
  */
17
- export declare function setupListbox(options?: ListboxOptions): ListboxHandle;
19
+ export declare function setupListbox(options?: CompositeOptions): ListboxHandle;
@@ -1,4 +1,4 @@
1
- import type { ListboxHandle } from '../Listbox/types';
1
+ import type { CompositeHandle } from '../Composite/types';
2
2
  /** Setters invoked by `subscribeListboxState` when handle events fire. */
3
3
  export interface ListboxStateSetters {
4
4
  /** Called immediately with the current loading state, then on every `loadingChange` event. */
@@ -9,10 +9,10 @@ export interface ListboxStateSetters {
9
9
  setIsOpen: (value: boolean) => void;
10
10
  }
11
11
  /**
12
- * Subscribe to the listbox handle events needed by `ListboxState`.
12
+ * Subscribe to the listbox handle events needed by `CompositeStatus`.
13
13
  *
14
14
  * Manages three subscriptions:
15
- * - `loadingChange` → `setIsLoading` (+ synchronous initial read of `list.isLoading`)
15
+ * - `loadingChange` → `setIsLoading` (+ synchronous initial read of the `loadingChange` snapshot)
16
16
  * - `loadingAnnouncement` → `setShouldAnnounce`
17
17
  * - `open` → `setIsOpen` (deferred by {@link OPEN_ANNOUNCEMENT_DELAY}ms when shown, immediate when hidden)
18
18
  * (a standalone listbox is always visible: `setIsOpen(true)` once, no subscription)
@@ -21,4 +21,4 @@ export interface ListboxStateSetters {
21
21
  * @param setters Framework-specific state setters.
22
22
  * @returns A cleanup function that unsubscribes all events and clears timers.
23
23
  */
24
- export declare function subscribeListboxState(list: ListboxHandle, setters: ListboxStateSetters): () => void;
24
+ export declare function subscribeListboxState(list: CompositeHandle, setters: ListboxStateSetters): () => void;
@@ -1,4 +1,6 @@
1
- import type { FocusNavigationController } from '../../utils/focusNavigation';
1
+ import type { CompositeHandle } from '../Composite/types';
2
+ /** Pattern of a mounted listbox element (from its role): `'listbox'` or `'grid'`. */
3
+ export type ListboxType = 'listbox' | 'grid';
2
4
  /** Section visibility state tracked per registration. */
3
5
  export interface SectionState {
4
6
  hidden: boolean;
@@ -14,133 +16,15 @@ export interface OptionRegistration {
14
16
  callback: (isFiltered: boolean) => void;
15
17
  lastFiltered: boolean;
16
18
  }
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
19
  /**
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`, …).
20
+ * Handle returned by {@link setupListbox}: the composite handle (WAI-ARIA listbox or grid pattern),
21
+ * plus the option and section registry.
58
22
  */
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;
23
+ export interface ListboxHandle extends CompositeHandle {
136
24
  /** Register an option element for filter notifications. Returns a cleanup function. */
137
25
  registerOption(element: HTMLElement, onFilterChange: (isFiltered: boolean) => void): () => void;
138
- /** Set the filter value and notify all registered options. */
139
- setFilter(filterValue: string): void;
140
26
  /** Re-evaluate the filter state of a single registered option. */
141
27
  refilterOption(element: HTMLElement): void;
142
28
  /** Register a section element for state notifications. Returns a cleanup function. */
143
29
  registerSection(element: HTMLElement, onChange: (state: SectionState) => void): () => void;
144
- /** Register a skeleton placeholder. Returns a cleanup function. */
145
- registerSkeleton(): () => void;
146
30
  }
@@ -1,30 +1,6 @@
1
- import type { OptionRegistration, SectionRegistration } from './types';
2
- /**
3
- * Get the value for an option element.
4
- * Uses `data-value` when set; falls back to the element's trimmed `textContent`.
5
- *
6
- * This is the *selection* value , which may differ from the visible label
7
- */
8
- export declare function getOptionValue(option: HTMLElement): string;
9
- /**
10
- * Get the visible label for an option element (its trimmed `textContent`).
11
- *
12
- * Used for typeahead matching: the user types the characters they see, which is the
13
- * option's label — not its `data-value` (which can be an unrelated id).
14
- */
15
- export declare function getOptionLabel(option: HTMLElement): string;
16
- /** Returns true when an option carries aria-disabled="true". */
17
- export declare function isOptionDisabled(option: HTMLElement): boolean;
1
+ import type { CompositeHandle } from '../Composite/types';
2
+ import type { ListboxHandle } from './types';
3
+ /** Whether a composite handle is a listbox handle (it has the option registry). */
4
+ export declare function isListboxHandle(handle: CompositeHandle | null | undefined): handle is ListboxHandle;
18
5
  /** Returns true when the cell is NOT the first gridcell in its row (i.e., it's an action cell). */
19
6
  export declare function isActionCell(cell: HTMLElement): boolean;
20
- export declare const isSelected: (el: Element) => boolean;
21
- /**
22
- * Compute the current state of a section and notify when it changed.
23
- *
24
- * Section state:
25
- * - `hidden`: true when the section has registered options but all are filtered out.
26
- * - `aria-hidden`: true when the section has no registered options at all (skeleton-only).
27
- *
28
- * At most one of `hidden` / `aria-hidden` is true at a time.
29
- */
30
- export declare function notifySection(sectionElement: HTMLElement, sectionRegistrations: Map<HTMLElement, SectionRegistration>, optionRegistrations: Map<HTMLElement, OptionRegistration>, force?: boolean): void;
package/lumx.css CHANGED
@@ -5721,7 +5721,7 @@ table {
5721
5721
  .lumx-combobox-popover__scroll {
5722
5722
  overflow-y: auto;
5723
5723
  }
5724
- .lumx-combobox-popover:empty, .lumx-combobox-popover:not(:has(.lumx-listbox-option)):not(:has(.lumx-listbox-state)):not(:has(.lumx-listbox-option-skeleton)) {
5724
+ .lumx-combobox-popover:not(:has(:is([role=listbox], [role=grid]):not([hidden]), .lumx-composite-status)) {
5725
5725
  display: none;
5726
5726
  }
5727
5727
 
@@ -5913,6 +5913,17 @@ table {
5913
5913
  margin-left: 52px;
5914
5914
  }
5915
5915
 
5916
+ /* ==========================================================================
5917
+ Composite
5918
+ ========================================================================== */
5919
+ .lumx-composite-status {
5920
+ text-align: center;
5921
+ }
5922
+
5923
+ .lumx-composite-item__selection-icon {
5924
+ margin: auto;
5925
+ }
5926
+
5916
5927
  /* ==========================================================================
5917
5928
  Date picker
5918
5929
  ========================================================================== */
@@ -8097,14 +8108,10 @@ table {
8097
8108
  /* ==========================================================================
8098
8109
  Listbox
8099
8110
  ========================================================================== */
8100
- .lumx-listbox-list:empty, .lumx-listbox-list:not(:has(.lumx-listbox-option)):not(:has(.lumx-listbox-state)):not(:has(.lumx-listbox-option-skeleton)) {
8111
+ .lumx-listbox-list:empty {
8101
8112
  display: none;
8102
8113
  }
8103
8114
 
8104
- .lumx-listbox-state {
8105
- text-align: center;
8106
- }
8107
-
8108
8115
  .lumx-listbox-option-skeleton .lumx-skeleton-typography {
8109
8116
  width: min(65%, 200px);
8110
8117
  }
@@ -8114,9 +8121,6 @@ table {
8114
8121
  .lumx-listbox-option-skeleton:nth-child(3n+2) .lumx-skeleton-typography {
8115
8122
  width: min(55%, 170px);
8116
8123
  }
8117
- .lumx-listbox-option__selection-icon {
8118
- margin: auto;
8119
- }
8120
8124
  .lumx-listbox-option .lumx-list-item__wrapper,
8121
8125
  .lumx-listbox-option .lumx-list-item__content {
8122
8126
  min-width: 0;
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.27.0",
10
+ "@lumx/icons": "^4.27.1-alpha.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.27.0",
69
+ "version": "4.27.1-alpha.1",
70
70
  "devDependencies": {
71
71
  "@rollup/plugin-typescript": "^12.3.0",
72
72
  "@testing-library/dom": "^10.4.1",
@@ -86,8 +86,9 @@
86
86
  "tinycolor2": "^1.4.1",
87
87
  "typescript": "^5.4.3",
88
88
  "version-changelog": "^3.1.1",
89
- "vite": "^7.3.5",
89
+ "vite": "^7.3.7",
90
90
  "vite-tsconfig-paths": "^5.1.4",
91
91
  "vitest": "^4.1.11"
92
- }
92
+ },
93
+ "stableVersion": "4.27.0"
93
94
  }
@@ -6,6 +6,7 @@
6
6
  @import "./components/chip/index";
7
7
  @import "./components/combobox/index";
8
8
  @import "./components/comment-block/index";
9
+ @import "./components/composite/index";
9
10
  @import "./components/date-picker/index";
10
11
  @import "./components/dialog/index";
11
12
  @import "./components/divider/index";
@@ -2,7 +2,7 @@
2
2
  Combobox
3
3
  ========================================================================== */
4
4
 
5
- // NB: list, option, section and state styles live in `components/list-box`.
5
+ // NB: list, option and section styles live in `components/list-box`, the state styles in `components/composite`.
6
6
 
7
7
  // ---- Input -----------------------
8
8
  .#{$lumx-base-prefix}-combobox-input {
@@ -21,11 +21,11 @@
21
21
  overflow-y: auto;
22
22
  }
23
23
 
24
- // Hide popover when there is no option, no state, and no skeleton
25
- &:empty,
26
- &:not(:has(.#{$lumx-base-prefix}-listbox-option)):not(:has(.#{$lumx-base-prefix}-listbox-state)):not(
27
- :has(.#{$lumx-base-prefix}-listbox-option-skeleton)
28
- ) {
24
+ // Hide the popover when it holds no visible list (the composite sets `hidden` on a list without visible
25
+ // content) and no state
26
+ $visible-list: ':is([role="listbox"], [role="grid"]):not([hidden])';
27
+
28
+ &:not(:has(#{$visible-list}, .#{$lumx-base-prefix}-composite-status)) {
29
29
  display: none;
30
30
  }
31
31
  }
@@ -0,0 +1,20 @@
1
+ /* ==========================================================================
2
+ Composite
3
+ ========================================================================== */
4
+
5
+ // Parts shared by the composite widgets (listbox, grid, tree).
6
+
7
+ // ---- Status -----------------------
8
+
9
+ .#{$lumx-base-prefix}-composite-status {
10
+ text-align: center;
11
+ }
12
+
13
+ // ---- Item -----------------------
14
+
15
+ .#{$lumx-base-prefix}-composite-item {
16
+ // Selection state icon, centered in the `after` slot
17
+ &__selection-icon {
18
+ margin: auto;
19
+ }
20
+ }
@@ -7,20 +7,10 @@
7
7
 
8
8
  // ---- List -----------------------
9
9
 
10
- // Hide list when there is no option, no state, and no skeleton
11
- .#{$lumx-base-prefix}-listbox-list {
12
- &:empty,
13
- &:not(:has(.#{$lumx-base-prefix}-listbox-option)):not(:has(.#{$lumx-base-prefix}-listbox-state)):not(
14
- :has(.#{$lumx-base-prefix}-listbox-option-skeleton)
15
- ) {
16
- display: none;
17
- }
18
- }
19
-
20
- // ---- State -----------------------
21
-
22
- .#{$lumx-base-prefix}-listbox-state {
23
- text-align: center;
10
+ // The composite sets `hidden` on the list when it has no visible content (see `setupComposite`).
11
+ // Before the composite mounts: hide an empty list.
12
+ .#{$lumx-base-prefix}-listbox-list:empty {
13
+ display: none;
24
14
  }
25
15
 
26
16
  // ---- Option -----------------------
@@ -41,11 +31,6 @@
41
31
  }
42
32
  }
43
33
 
44
- // Selection state icon (select options), centered in the `after` slot
45
- &__selection-icon {
46
- margin: auto;
47
- }
48
-
49
34
  // Allow flex items to shrink below their content width so `truncate` text shows an ellipsis
50
35
  .#{$lumx-base-prefix}-list-item__wrapper,
51
36
  .#{$lumx-base-prefix}-list-item__content {
@@ -32,7 +32,7 @@
32
32
  &:hover::before,
33
33
  &[data-focus-visible-added]::before,
34
34
  &[data-lumx-hover]::before {
35
- @include lumx-state(lumx-base-const('state', 'HOVER'), lumx-base-const('emphasis', 'LOW'), 'dark');
35
+ @include lumx-action-area-overlay-hover('dark');
36
36
  }
37
37
 
38
38
  &:active::before,
@@ -46,7 +46,7 @@
46
46
  &:hover::before,
47
47
  &[data-focus-visible-added]::before,
48
48
  &[data-lumx-hover]::before {
49
- @include lumx-state(lumx-base-const('state', 'HOVER'), lumx-base-const('emphasis', 'LOW'), 'light');
49
+ @include lumx-action-area-overlay-hover('light');
50
50
  }
51
51
 
52
52
  &:active::before,
@@ -65,8 +65,7 @@
65
65
  }
66
66
 
67
67
  &--focus-inset[data-focus-visible-added]::before {
68
- outline-style: solid;
69
- outline-offset: -2px;
68
+ @include lumx-action-area-focus-inset;
70
69
  }
71
70
 
72
71
  &--theme-dark[data-focus-visible-added]::before {
@@ -16,3 +16,14 @@ $interactive: 'a, button, input, select, textarea, label, [tabindex]';
16
16
  z-index: 1;
17
17
  }
18
18
  }
19
+
20
+ // Hover (and keyboard focus) state of an action overlay (`::before`).
21
+ @mixin lumx-action-area-overlay-hover($theme: 'dark') {
22
+ @include lumx-state(lumx-base-const('state', 'HOVER'), lumx-base-const('emphasis', 'LOW'), $theme);
23
+ }
24
+
25
+ // Focus outline of an action overlay (`::before`), inside the action.
26
+ @mixin lumx-action-area-focus-inset {
27
+ outline-style: solid;
28
+ outline-offset: -2px;
29
+ }
@@ -1,13 +0,0 @@
1
- export interface ListboxOptionSelectionIconProps {
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 ListboxOptionSelectionIcon: ({ selectionType, isSelected }: ListboxOptionSelectionIconProps) => import("react").JSX.Element | null;