@lumx/core 4.27.1-alpha.1 → 4.28.0-next.0

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.
@@ -1,4 +1,5 @@
1
- import type { LumxClassName } from '../../types';
1
+ import type { HasClassName, LumxClassName } from '../../types';
2
+ import type { CompositeState } from './types';
2
3
  /**
3
4
  * Component display name.
4
5
  */
@@ -12,7 +13,7 @@ export declare const LEGACY_CLASSNAME = "lumx-listbox-state lumx-combobox-state"
12
13
  /**
13
14
  * Defines the props for the core CompositeStatus template.
14
15
  */
15
- export interface CompositeStatusProps {
16
+ export interface CompositeStatusProps extends HasClassName {
16
17
  /**
17
18
  * Message to display when the composite has no visible items.
18
19
  * Can be a plain string or a function receiving the current input value (for dynamic messages).
@@ -44,31 +45,10 @@ export interface CompositeStatusProps {
44
45
  */
45
46
  loadingMessage?: string;
46
47
  /**
47
- * Composite state
48
+ * The live region state of the composite (the `stateChange` snapshot, see `CompositeState`).
49
+ * Without it (no composite handle yet), nothing renders.
48
50
  */
49
- state?: {
50
- /**
51
- * The number of currently visible items.
52
- * Driven by the framework wrapper via the composite handle's `optionsChange` event.
53
- */
54
- optionsLength?: number;
55
- /**
56
- * The current value of the combobox input.
57
- * Passed to `emptyMessage` when it is a function.
58
- */
59
- inputValue?: string;
60
- /**
61
- * Whether loading is active (immediate, from `loadingChange` event).
62
- * Used to suppress false "empty" state while data is loading.
63
- */
64
- isLoading?: boolean;
65
- /**
66
- * Whether the combobox popover is open.
67
- * Used to gate live region content so screen readers announce messages
68
- * when the popover opens (content insertion triggers `aria-live` announcement).
69
- */
70
- isOpen?: boolean;
71
- };
51
+ state?: CompositeState;
72
52
  }
73
53
  /**
74
54
  * Components injected by the framework wrapper (dependency injection).
@@ -15,6 +15,28 @@ export interface CompositeFilter {
15
15
  }
16
16
  /** Event name for the active state of one item. */
17
17
  export type OptionActiveEvent = `optionActive:${string}`;
18
+ /**
19
+ * State of a composite for its live region (see `CompositeStatus`): the item count, the loading state and the
20
+ * open state, as one snapshot (see {@link CompositeEventMap.stateChange}).
21
+ */
22
+ export interface CompositeState {
23
+ /** The number of visible items. */
24
+ optionsLength: number;
25
+ /** The current input value (combobox only, empty string otherwise). */
26
+ inputValue: string;
27
+ /** Whether the item count must not be announced (set by the composite specialization). */
28
+ isCountHidden: boolean;
29
+ /** Whether root skeletons are registered (loading), at once. */
30
+ isLoading: boolean;
31
+ /** Whether the loading lasted long enough to be announced (500ms after skeletons mount while open). */
32
+ isLoadingAnnounced: boolean;
33
+ /**
34
+ * Whether the items are open for the live region: set 100ms after the composite opens (the popover must
35
+ * be in the accessibility tree before the live region content changes), cleared at once when it closes.
36
+ * A standalone composite is always open.
37
+ */
38
+ isOpenForAnnouncement: boolean;
39
+ }
18
40
  /** Map of composite event names to their payload types. */
19
41
  export interface CompositeEventMap {
20
42
  /** Fired when the active descendant changes (visual focus). Payload: the active item id or null. */
@@ -31,20 +53,22 @@ export interface CompositeEventMap {
31
53
  } | undefined;
32
54
  /**
33
55
  * 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.
56
+ * between 0 and >0). Used for `aria-busy` on the list. The live region reads the loading state and
57
+ * the loading announcement from {@link stateChange}.
35
58
  */
36
59
  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
60
  /**
43
61
  * Fired when the items become visible or hidden (see {@link CompositeHandle.setOpen}).
44
62
  * Inside a combobox, this is the combobox open state. A standalone composite is open from
45
63
  * creation and never closes.
46
64
  */
47
65
  open: boolean;
66
+ /**
67
+ * Fired when any field of the live region state changes (see {@link CompositeState}): the visible count,
68
+ * the loading state, the loading announcement, and the delayed open state. Has a value from creation
69
+ * (`undefined` only as the initial value of the framework hooks, without a handle).
70
+ */
71
+ stateChange: CompositeState | undefined;
48
72
  /**
49
73
  * Fired only when this item becomes the active descendant (true)
50
74
  * or stops being the active descendant (false).
@@ -56,7 +80,7 @@ export interface CompositeEventMap {
56
80
  * Link to a parent widget that owns focus (e.g. a combobox trigger).
57
81
  * Without it, the composite is standalone and owns focus itself.
58
82
  * The parent sets the open state ({@link CompositeHandle.setOpen}) and observes the composite through its
59
- * events (e.g. `optionsChange`).
83
+ * events (e.g. `stateChange`).
60
84
  */
61
85
  export interface CompositeFocusOwnerLink {
62
86
  /** The element that holds DOM focus and `aria-activedescendant`. */
@@ -13,5 +13,3 @@ export { ListboxOptionMoreInfo } from './ListboxOptionMoreInfo';
13
13
  export type { ListboxOptionMoreInfoProps, ListboxOptionMoreInfoPropsToOverride, ListboxOptionMoreInfoComponents, } from './ListboxOptionMoreInfo';
14
14
  export { ListboxSection } from './ListboxSection';
15
15
  export type { ListboxSectionProps, ListboxSectionPropsToOverride, ListboxSectionComponents } from './ListboxSection';
16
- export { subscribeListboxState } from './subscribeListboxState';
17
- export type { ListboxStateSetters } from './subscribeListboxState';
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.1-alpha.1",
10
+ "@lumx/icons": "^4.28.0-next.0",
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.1-alpha.1",
69
+ "version": "4.28.0-next.0",
70
70
  "devDependencies": {
71
71
  "@rollup/plugin-typescript": "^12.3.0",
72
72
  "@testing-library/dom": "^10.4.1",
@@ -1,24 +0,0 @@
1
- import type { CompositeHandle } from '../Composite/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 `CompositeStatus`.
13
- *
14
- * Manages three subscriptions:
15
- * - `loadingChange` → `setIsLoading` (+ synchronous initial read of the `loadingChange` snapshot)
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: CompositeHandle, setters: ListboxStateSetters): () => void;