@lumx/core 4.26.0-next.1 → 4.26.0-next.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.
- package/components-and-utils.css +39 -35
- package/js/components/Combobox/ComboboxOptionTests.d.ts +3 -3
- package/js/components/Combobox/ComboboxPopover.d.ts +1 -1
- package/js/components/Combobox/constants.d.ts +0 -4
- package/js/components/Combobox/index.d.ts +0 -16
- package/js/components/Combobox/setupCombobox.d.ts +2 -2
- package/js/components/Combobox/setupComboboxButton.d.ts +4 -3
- package/js/components/Combobox/setupComboboxInput.d.ts +1 -1
- package/js/components/Combobox/types.d.ts +14 -127
- package/js/components/{Combobox/ComboboxList.d.ts → Listbox/ListboxList.d.ts} +14 -8
- package/js/components/{Combobox/ComboboxOption.d.ts → Listbox/ListboxOption.d.ts} +17 -11
- package/js/components/{Combobox/ComboboxOptionAction.d.ts → Listbox/ListboxOptionAction.d.ts} +11 -5
- package/js/components/{Combobox/ComboboxOptionMoreInfo.d.ts → Listbox/ListboxOptionMoreInfo.d.ts} +14 -8
- package/js/components/{Combobox/ComboboxSelectionIcon.d.ts → Listbox/ListboxOptionSelectionIcon.d.ts} +2 -2
- package/js/components/{Combobox/ComboboxOptionSkeleton.d.ts → Listbox/ListboxOptionSkeleton.d.ts} +14 -8
- package/js/components/{Combobox/ComboboxSection.d.ts → Listbox/ListboxSection.d.ts} +17 -11
- package/js/components/{Combobox/ComboboxState.d.ts → Listbox/ListboxState.d.ts} +12 -6
- package/js/components/Listbox/Tests.d.ts +43 -0
- package/js/components/Listbox/constants.d.ts +4 -0
- package/js/components/Listbox/index.d.ts +18 -0
- package/js/components/Listbox/navigation.d.ts +40 -0
- package/js/components/Listbox/setupListbox.d.ts +17 -0
- package/js/components/Listbox/subscribeListboxState.d.ts +24 -0
- package/js/components/Listbox/types.d.ts +146 -0
- package/js/components/{Combobox → Listbox}/utils.d.ts +2 -2
- package/js/components/Popover/Stories.d.ts +2 -2
- package/js/components/TimePickerField/index.d.ts +4 -4
- package/js/utils/select/renderSelectOptions.d.ts +1 -1
- package/lumx.css +39 -35
- package/package.json +2 -2
- package/scss/_components_classes.scss +1 -0
- package/scss/components/combobox/_index.scss +5 -57
- package/scss/components/list/_mixins.scss +5 -4
- package/scss/components/list-box/_index.scss +69 -0
- package/js/components/Combobox/setupListbox.d.ts +0 -23
- package/js/components/Combobox/subscribeComboboxState.d.ts +0 -23
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
* Defines the props for the core
|
|
3
|
+
* Defines the props for the core ListboxSection template.
|
|
4
4
|
*/
|
|
5
|
-
export interface
|
|
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
|
|
10
|
+
/** Section content (should be ListboxOption elements). */
|
|
11
11
|
children: JSXElement;
|
|
12
12
|
/** ref to the root element. */
|
|
13
13
|
ref?: CommonRef;
|
|
@@ -20,32 +20,38 @@ 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 (`
|
|
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<
|
|
29
|
+
* Used by `ReactToJSX<ListboxSectionProps, ListboxSectionPropsToOverride>`.
|
|
30
30
|
*/
|
|
31
|
-
export type
|
|
31
|
+
export type ListboxSectionPropsToOverride = 'children';
|
|
32
32
|
/**
|
|
33
|
-
* Injected framework-specific components for
|
|
33
|
+
* Injected framework-specific components for ListboxSection rendering.
|
|
34
34
|
*/
|
|
35
|
-
export interface
|
|
35
|
+
export interface ListboxSectionComponents {
|
|
36
36
|
/** ListSection component (framework-specific). */
|
|
37
37
|
ListSection: any;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Component display name.
|
|
41
41
|
*/
|
|
42
|
-
export declare const COMPONENT_NAME = "
|
|
42
|
+
export declare const COMPONENT_NAME = "ListboxSection";
|
|
43
43
|
/**
|
|
44
44
|
* Component default class name and class prefix.
|
|
45
45
|
*/
|
|
46
46
|
export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Legacy class name, emitted next to `CLASSNAME` for backward compatibility.
|
|
49
|
+
*
|
|
50
|
+
* @deprecated Use `CLASSNAME` (`lumx-listbox-*`). The legacy `lumx-combobox-*` class will be removed in the next major version.
|
|
51
|
+
*/
|
|
52
|
+
export declare const LEGACY_CLASSNAME = "lumx-combobox-section";
|
|
53
|
+
/**
|
|
54
|
+
* ListboxSection core template.
|
|
49
55
|
* Renders a ListSection with combobox-specific ARIA roles.
|
|
50
56
|
*
|
|
51
57
|
* Framework-specific components (ListSection) are passed as a second argument
|
|
@@ -55,4 +61,4 @@ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
|
|
|
55
61
|
* @param components Injected framework-specific components.
|
|
56
62
|
* @return JSX element.
|
|
57
63
|
*/
|
|
58
|
-
export declare const
|
|
64
|
+
export declare const ListboxSection: (props: ListboxSectionProps, { ListSection }: ListboxSectionComponents) => import("react").JSX.Element;
|
|
@@ -3,15 +3,21 @@ import type { TextProps } from '../Text';
|
|
|
3
3
|
/**
|
|
4
4
|
* Component display name.
|
|
5
5
|
*/
|
|
6
|
-
export declare const COMPONENT_NAME = "
|
|
6
|
+
export declare const COMPONENT_NAME = "ListboxState";
|
|
7
7
|
/**
|
|
8
8
|
* Component default class name and class prefix.
|
|
9
9
|
*/
|
|
10
10
|
export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
|
|
11
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
19
|
*/
|
|
14
|
-
export interface
|
|
20
|
+
export interface ListboxStateProps {
|
|
15
21
|
/**
|
|
16
22
|
* Message to display when the list has no visible options.
|
|
17
23
|
* Can be a plain string or a function receiving the current input value (for dynamic messages).
|
|
@@ -72,7 +78,7 @@ export interface ComboboxStateProps {
|
|
|
72
78
|
/**
|
|
73
79
|
* Components injected by the framework wrapper (dependency injection).
|
|
74
80
|
*/
|
|
75
|
-
export interface
|
|
81
|
+
export interface ListboxStateComponents {
|
|
76
82
|
/**
|
|
77
83
|
* GenericBlock component (framework-specific, e.g. React GenericBlock with FlexBox handling).
|
|
78
84
|
*/
|
|
@@ -83,7 +89,7 @@ export interface ComboboxStateComponents {
|
|
|
83
89
|
Text: (props: TextProps) => any;
|
|
84
90
|
}
|
|
85
91
|
/**
|
|
86
|
-
*
|
|
92
|
+
* ListboxState core template.
|
|
87
93
|
* Renders empty/error/option-count state messages inside the combobox popover.
|
|
88
94
|
* The block itself acts as a screen reader live region (`role="status" aria-live="polite"`).
|
|
89
95
|
*
|
|
@@ -96,4 +102,4 @@ export interface ComboboxStateComponents {
|
|
|
96
102
|
* @param components Injected framework-specific components.
|
|
97
103
|
* @return JSX element or null when no state is active.
|
|
98
104
|
*/
|
|
99
|
-
export declare const
|
|
105
|
+
export declare const ListboxState: (props: ListboxStateProps, { GenericBlock, Text }: ListboxStateComponents) => import("react").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
SelectionIcon: any;
|
|
11
|
+
}
|
|
12
|
+
type RenderResult = {
|
|
13
|
+
unmount: () => void;
|
|
14
|
+
container: HTMLElement;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Options to set up the listbox test suite.
|
|
18
|
+
* Injected by the framework-specific test file (React or Vue).
|
|
19
|
+
*/
|
|
20
|
+
export interface ListboxTestSetup {
|
|
21
|
+
components: {
|
|
22
|
+
Listbox: ListboxNamespace;
|
|
23
|
+
/** Combobox namespace (to test the listbox inside a combobox context). */
|
|
24
|
+
Combobox: {
|
|
25
|
+
Provider: any;
|
|
26
|
+
Button: any;
|
|
27
|
+
Popover: any;
|
|
28
|
+
List: any;
|
|
29
|
+
Option: any;
|
|
30
|
+
};
|
|
31
|
+
IconButton: any;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Render a template with controlled state management.
|
|
35
|
+
* Mirrors the withValueOnChange Storybook decorator.
|
|
36
|
+
*/
|
|
37
|
+
renderWithState: (template: (props: any) => any, initialArgs?: Record<string, any>, options?: {
|
|
38
|
+
onChangeProp?: string;
|
|
39
|
+
valueExtract?: (v: any) => any;
|
|
40
|
+
}) => RenderResult;
|
|
41
|
+
}
|
|
42
|
+
export default function listboxTests({ components: { Listbox, Combobox, IconButton }, renderWithState, }: ListboxTestSetup): void;
|
|
43
|
+
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
|
|
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
|
|
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" | "
|
|
69
|
-
mapping: Record<string, "top" | "right" | "bottom" | "left" | "auto" | "
|
|
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 {
|
|
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 `
|
|
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<
|
|
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<
|
|
110
|
+
}) => Partial<ListboxOptionProps>;
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* Injected framework-specific components for TimePickerField rendering.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JSXElement } from '../../types';
|
|
2
2
|
import type { BaseSelectComponents, RenderSelectOptionsProps } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Render options as
|
|
4
|
+
* Render options as ListboxOption elements.
|
|
5
5
|
* Framework-specific components are passed as a second argument.
|
|
6
6
|
*/
|
|
7
7
|
export declare function renderSelectOptions<O>(props: RenderSelectOptionsProps<O>, components: BaseSelectComponents): JSXElement;
|
package/lumx.css
CHANGED
|
@@ -5737,43 +5737,10 @@ table {
|
|
|
5737
5737
|
display: block;
|
|
5738
5738
|
scroll-snap-align: end;
|
|
5739
5739
|
}
|
|
5740
|
-
|
|
5741
|
-
.lumx-combobox-popover:empty, .lumx-combobox-popover:not(:has(.lumx-combobox-option)):not(:has(.lumx-combobox-state)):not(:has(.lumx-combobox-option-skeleton)),
|
|
5742
|
-
.lumx-combobox-list:empty,
|
|
5743
|
-
.lumx-combobox-list:not(:has(.lumx-combobox-option)):not(:has(.lumx-combobox-state)):not(:has(.lumx-combobox-option-skeleton)) {
|
|
5740
|
+
.lumx-combobox-popover:empty, .lumx-combobox-popover:not(:has(.lumx-listbox-option)):not(:has(.lumx-listbox-state)):not(:has(.lumx-listbox-option-skeleton)) {
|
|
5744
5741
|
display: none;
|
|
5745
5742
|
}
|
|
5746
5743
|
|
|
5747
|
-
.lumx-combobox-state {
|
|
5748
|
-
text-align: center;
|
|
5749
|
-
}
|
|
5750
|
-
|
|
5751
|
-
.lumx-combobox-option-skeleton .lumx-skeleton-typography {
|
|
5752
|
-
width: min(65%, 200px);
|
|
5753
|
-
}
|
|
5754
|
-
.lumx-combobox-option-skeleton:nth-child(3n+1) .lumx-skeleton-typography {
|
|
5755
|
-
width: min(70%, 230px);
|
|
5756
|
-
}
|
|
5757
|
-
.lumx-combobox-option-skeleton:nth-child(3n+2) .lumx-skeleton-typography {
|
|
5758
|
-
width: min(55%, 170px);
|
|
5759
|
-
}
|
|
5760
|
-
.lumx-combobox-option__selection-icon {
|
|
5761
|
-
margin: auto;
|
|
5762
|
-
}
|
|
5763
|
-
.lumx-combobox-option .lumx-list-item__wrapper,
|
|
5764
|
-
.lumx-combobox-option .lumx-list-item__content {
|
|
5765
|
-
min-width: 0;
|
|
5766
|
-
}
|
|
5767
|
-
.lumx-combobox-option .lumx-list-item__content {
|
|
5768
|
-
display: flex;
|
|
5769
|
-
flex-direction: column;
|
|
5770
|
-
justify-items: center;
|
|
5771
|
-
}
|
|
5772
|
-
.lumx-combobox-option-more-info__popover {
|
|
5773
|
-
max-width: 256px;
|
|
5774
|
-
padding: 16px;
|
|
5775
|
-
}
|
|
5776
|
-
|
|
5777
5744
|
/* ==========================================================================
|
|
5778
5745
|
Comment block
|
|
5779
5746
|
========================================================================== */
|
|
@@ -8143,6 +8110,43 @@ table {
|
|
|
8143
8110
|
opacity: 1;
|
|
8144
8111
|
}
|
|
8145
8112
|
}
|
|
8113
|
+
/* ==========================================================================
|
|
8114
|
+
Listbox
|
|
8115
|
+
========================================================================== */
|
|
8116
|
+
.lumx-listbox-list:empty, .lumx-listbox-list:not(:has(.lumx-listbox-option)):not(:has(.lumx-listbox-state)):not(:has(.lumx-listbox-option-skeleton)) {
|
|
8117
|
+
display: none;
|
|
8118
|
+
}
|
|
8119
|
+
|
|
8120
|
+
.lumx-listbox-state {
|
|
8121
|
+
text-align: center;
|
|
8122
|
+
}
|
|
8123
|
+
|
|
8124
|
+
.lumx-listbox-option-skeleton .lumx-skeleton-typography {
|
|
8125
|
+
width: min(65%, 200px);
|
|
8126
|
+
}
|
|
8127
|
+
.lumx-listbox-option-skeleton:nth-child(3n+1) .lumx-skeleton-typography {
|
|
8128
|
+
width: min(70%, 230px);
|
|
8129
|
+
}
|
|
8130
|
+
.lumx-listbox-option-skeleton:nth-child(3n+2) .lumx-skeleton-typography {
|
|
8131
|
+
width: min(55%, 170px);
|
|
8132
|
+
}
|
|
8133
|
+
.lumx-listbox-option__selection-icon {
|
|
8134
|
+
margin: auto;
|
|
8135
|
+
}
|
|
8136
|
+
.lumx-listbox-option .lumx-list-item__wrapper,
|
|
8137
|
+
.lumx-listbox-option .lumx-list-item__content {
|
|
8138
|
+
min-width: 0;
|
|
8139
|
+
}
|
|
8140
|
+
.lumx-listbox-option .lumx-list-item__content {
|
|
8141
|
+
display: flex;
|
|
8142
|
+
flex-direction: column;
|
|
8143
|
+
justify-items: center;
|
|
8144
|
+
}
|
|
8145
|
+
.lumx-listbox-option-more-info__popover {
|
|
8146
|
+
max-width: 256px;
|
|
8147
|
+
padding: 16px;
|
|
8148
|
+
}
|
|
8149
|
+
|
|
8146
8150
|
/* ==========================================================================
|
|
8147
8151
|
Index
|
|
8148
8152
|
========================================================================== */
|
|
@@ -9036,7 +9040,7 @@ table {
|
|
|
9036
9040
|
margin: 8px 0;
|
|
9037
9041
|
background-color: var(--lumx-color-dark-L5);
|
|
9038
9042
|
}
|
|
9039
|
-
.lumx-list-section:
|
|
9043
|
+
.lumx-list-section:has(+ :not(.lumx-list-divider, [hidden], :empty))::after {
|
|
9040
9044
|
content: "";
|
|
9041
9045
|
display: block;
|
|
9042
9046
|
height: 1px;
|
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.26.0-next.
|
|
10
|
+
"@lumx/icons": "^4.26.0-next.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.26.0-next.
|
|
69
|
+
"version": "4.26.0-next.2",
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
72
72
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
@import "./components/input-label/index";
|
|
26
26
|
@import "./components/input-required-legend/index";
|
|
27
27
|
@import "./components/lightbox/index";
|
|
28
|
+
@import "./components/list-box/index";
|
|
28
29
|
@import "./components/link/index";
|
|
29
30
|
@import "./components/link-preview/index";
|
|
30
31
|
@import "./components/list/index";
|