@lumx/core 4.27.1-alpha.1 → 4.27.1-alpha.3

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 (32) hide show
  1. package/components-and-utils.css +83 -2
  2. package/js/components/Combobox/Tests.d.ts +9 -0
  3. package/js/components/Combobox/index.d.ts +1 -1
  4. package/js/components/Combobox/setupCombobox.d.ts +13 -11
  5. package/js/components/Combobox/setupComboboxButton.d.ts +2 -2
  6. package/js/components/Combobox/setupComboboxInput.d.ts +2 -2
  7. package/js/components/Combobox/types.d.ts +56 -17
  8. package/js/components/Composite/CompositeStatus.d.ts +8 -27
  9. package/js/components/Composite/types.d.ts +43 -9
  10. package/js/components/Composite/utils.d.ts +2 -0
  11. package/js/components/Listbox/index.d.ts +0 -2
  12. package/js/components/TreeList/Stories.d.ts +82 -0
  13. package/js/components/TreeList/TestStories.d.ts +88 -0
  14. package/js/components/TreeList/Tests.d.ts +51 -0
  15. package/js/components/TreeList/TreeList.d.ts +60 -0
  16. package/js/components/TreeList/TreeListItem.d.ts +84 -0
  17. package/js/components/TreeList/TreeListSection.d.ts +52 -0
  18. package/js/components/TreeList/dom.d.ts +61 -0
  19. package/js/components/TreeList/index.d.ts +11 -0
  20. package/js/components/TreeList/navigation.d.ts +15 -0
  21. package/js/components/TreeList/selection.d.ts +9 -0
  22. package/js/components/TreeList/setupTreeList.d.ts +18 -0
  23. package/js/components/TreeList/types.d.ts +65 -0
  24. package/js/components/TreeList/utils.d.ts +4 -0
  25. package/js/utils/string/includesIgnoreCase.d.ts +2 -0
  26. package/lumx.css +83 -2
  27. package/package.json +3 -4
  28. package/scss/_components_classes.scss +1 -0
  29. package/scss/components/combobox/_index.scss +1 -1
  30. package/scss/components/list/_mixins.scss +4 -3
  31. package/scss/components/tree-list/_index.scss +145 -0
  32. package/js/components/Listbox/subscribeListboxState.d.ts +0 -24
@@ -0,0 +1,51 @@
1
+ /** Combobox components used by the tree tests (the shared list sub-components work in a tree too). */
2
+ export interface TreeListComboboxNamespace {
3
+ Provider: any;
4
+ Input: any;
5
+ Button: any;
6
+ Popover: any;
7
+ OptionSkeleton: any;
8
+ State: any;
9
+ List: any;
10
+ Option: any;
11
+ }
12
+ /** Components used by the tree tests and stories. */
13
+ export interface TreeListComponents {
14
+ /** The tree (standalone, or in a combobox). */
15
+ TreeList: any;
16
+ TreeListItem: any;
17
+ TreeListSection: any;
18
+ Combobox: TreeListComboboxNamespace;
19
+ }
20
+ type RenderResult = {
21
+ unmount: () => void;
22
+ container: HTMLElement;
23
+ };
24
+ /**
25
+ * Options to set up the tree list test suite.
26
+ * Injected by the framework-specific test file (React or Vue).
27
+ */
28
+ export interface TreeListTestSetup {
29
+ components: TreeListComponents;
30
+ /**
31
+ * Render a template with controlled state management (one `value` state, set by the
32
+ * `onChangeProp` callback). Mirrors the withValueOnChange Storybook decorator.
33
+ */
34
+ renderWithState: (template: (props: any) => any, initialArgs?: Record<string, any>, options?: {
35
+ onChangeProp?: string;
36
+ valueExtract?: (v: any) => any;
37
+ }) => RenderResult;
38
+ }
39
+ /**
40
+ * Create framework-agnostic JSX templates for the tree tests (the reference tree of the spec).
41
+ * Exported so the test stories can reuse the same tree.
42
+ */
43
+ export declare function createTreeTemplates({ TreeList, TreeListItem, TreeListSection, Combobox }: TreeListComponents): {
44
+ inputTemplate: ({ value, onUpdate, onSelect, treeOnSelect, filter, selectionType, onOpenChange, onClick, nbOptionMessage, withoutState, snacks, }: any) => import("react").JSX.Element;
45
+ buttonTemplate: ({ value, onSelect, onOpenChange }: any) => import("react").JSX.Element;
46
+ lazyTemplate: ({ value, onChange, onOpenChange, load }: any) => import("react").JSX.Element;
47
+ standaloneTemplate: ({ value, onUpdate, onSelect, onOpenChange, onClick, selectionType }: any) => import("react").JSX.Element;
48
+ sectionTemplate: ({ value, onChange }: any) => import("react").JSX.Element;
49
+ };
50
+ export default function treeListTests({ components, renderWithState }: TreeListTestSetup): void;
51
+ export {};
@@ -0,0 +1,60 @@
1
+ import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
+ import type { TreeListSelectionType } from './selection';
3
+ /**
4
+ * Defines the props for the core TreeList template.
5
+ */
6
+ export interface TreeListProps extends HasClassName {
7
+ /** Accessible label of the tree (one of `aria-label` or `aria-labelledby` is required). */
8
+ 'aria-label'?: string;
9
+ /** ID of the element that labels the tree. */
10
+ 'aria-labelledby'?: string;
11
+ /**
12
+ * Indicates that the tree content is incomplete (root skeletons, the first load of the tree). Not rendered
13
+ * when false.
14
+ */
15
+ 'aria-busy'?: boolean;
16
+ /**
17
+ * Selection type: one selected tree item, or several (`aria-multiselectable`).
18
+ */
19
+ selectionType?: TreeListSelectionType;
20
+ /** Content (`TreeListItem` or `ListboxOptionSkeleton` elements). Render the states outside the tree. */
21
+ children?: JSXElement;
22
+ /** The ID of the tree element. */
23
+ id?: string;
24
+ /** Tab index (`0` on a standalone list, which owns focus). */
25
+ tabIndex?: number;
26
+ /** ref to the root element */
27
+ ref?: CommonRef;
28
+ }
29
+ /**
30
+ * Component display name.
31
+ */
32
+ export declare const COMPONENT_NAME = "TreeList";
33
+ /**
34
+ * Component default class name and class prefix.
35
+ */
36
+ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
37
+ /**
38
+ * Component default props.
39
+ */
40
+ export declare const DEFAULT_PROPS: {
41
+ readonly selectionType: "single";
42
+ };
43
+ /**
44
+ * TreeList core template: a list in the tree pattern (`<ul role="tree">`), with `TreeListItem` items.
45
+ * Nothing in the markup refers to a combobox: the framework wrapper links the tree to a combobox trigger,
46
+ * or makes it its own focus owner (standalone: `tabIndex={0}`).
47
+ *
48
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/treeview/
49
+ *
50
+ * @param props Component props.
51
+ * @return JSX element.
52
+ */
53
+ export declare const TreeList: {
54
+ (props: TreeListProps): import("react").JSX.Element;
55
+ displayName: string;
56
+ className: "lumx-tree-list";
57
+ defaultProps: {
58
+ readonly selectionType: "single";
59
+ };
60
+ };
@@ -0,0 +1,84 @@
1
+ import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
+ /**
3
+ * Injected framework-specific components for TreeListItem rendering.
4
+ */
5
+ export interface TreeListItemComponents {
6
+ /** Tooltip wrapper component (optional). Used when `tooltipProps` is provided. */
7
+ Tooltip?: any;
8
+ }
9
+ /**
10
+ * Defines the props for the core TreeListItem template.
11
+ */
12
+ export interface TreeListItemProps extends HasClassName {
13
+ /** Content of the row (the tree item label). */
14
+ label?: JSXElement;
15
+ /** The sub-items (`TreeListItem` or `ListboxOptionSkeleton` elements). */
16
+ children?: JSXElement;
17
+ /** A component to be rendered before the label (e.g. an icon or avatar). */
18
+ before?: JSXElement;
19
+ /** A component to be rendered after the label. */
20
+ after?: JSXElement;
21
+ /** Helper description (part of the filter match text). */
22
+ description?: string;
23
+ /** The value of the tree item. With a value, the tree item is selectable; without, it is not. */
24
+ value?: string;
25
+ /** Whether the tree item is selected (internal: from the tree `value`; no effect on a non-selectable tree item). */
26
+ isSelected?: boolean;
27
+ /** Props forwarded to a Tooltip wrapping the `role="treeitem"` element. */
28
+ tooltipProps?: Record<string, any>;
29
+ /** Extra props forwarded to the inner `role="treeitem"` element. */
30
+ actionProps?: Record<string, any>;
31
+ /** ref to the root `<li>` element. */
32
+ ref?: CommonRef;
33
+ /**
34
+ * Unique ID for the tree item element (internal). The IDs of the label, the description and the group are
35
+ * `<id>-label`, `<id>-description` and `<id>-group`.
36
+ */
37
+ id?: string;
38
+ /** Whether the tree item is a parent item (internal: it has sub-items, or it loads them on open). */
39
+ isParent?: boolean;
40
+ /** Whether the parent item is open (internal). */
41
+ isOpen?: boolean;
42
+ /** Whether the filter hides the tree item (internal). */
43
+ hidden?: boolean;
44
+ /** Nesting level of the tree item (internal, 0 at the root). Its group sets the level of the sub-items. */
45
+ level?: number;
46
+ /** On click on the tree item (and on Enter). */
47
+ handleClick?(): void;
48
+ /** On click on the expand toggle. */
49
+ handleToggleClick?(): void;
50
+ }
51
+ /**
52
+ * Props that React/Vue wrappers need to re-declare with framework-specific types.
53
+ */
54
+ export type TreeListItemPropsToOverride = 'label' | 'before' | 'after' | 'children' | 'tooltipProps' | 'actionProps';
55
+ /**
56
+ * Component display name.
57
+ */
58
+ export declare const COMPONENT_NAME = "TreeListItem";
59
+ /**
60
+ * Component default class name and class prefix.
61
+ */
62
+ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
63
+ /**
64
+ * TreeListItem core template: one tree item of a `TreeList`, with its sub-items in a group.
65
+ *
66
+ * - The `role="treeitem"` element is the row button. It holds the label and carries `aria-expanded`,
67
+ * `aria-selected` (only on a selectable tree item) and `aria-owns` (its group is a sibling, not a child).
68
+ * It is labelled by its label only (`aria-labelledby`), never by the text of the owned group.
69
+ * - The expand toggle is a sibling of the row button, hidden from assistive technologies. On a
70
+ * non-selectable parent item, it is the main action of the row (its overlay covers the row).
71
+ * - A closed group stays in the DOM, with `hidden`.
72
+ * - Each group sets the level of its sub-items (`--lumx-tree-list-level`): the rows read it as a left
73
+ * padding, so the hover and selected backgrounds stay full width at every depth.
74
+ * - The browser computes `aria-level`, `aria-setsize` and `aria-posinset` from the DOM.
75
+ *
76
+ * @param props Component props.
77
+ * @param components Injected framework-specific components.
78
+ * @return JSX element.
79
+ */
80
+ export declare const TreeListItem: {
81
+ (props: TreeListItemProps, { Tooltip }?: TreeListItemComponents): import("react").JSX.Element;
82
+ displayName: string;
83
+ className: "lumx-tree-list-item";
84
+ };
@@ -0,0 +1,52 @@
1
+ import type { CommonRef, HasClassName, JSXElement, LumxClassName } from '../../types';
2
+ /**
3
+ * Defines the props for the core TreeListSection template.
4
+ */
5
+ export interface TreeListSectionProps extends HasClassName {
6
+ /** Section label, shown as the section title (visual only). Without a label, the section is a plain group. */
7
+ label?: string | JSXElement;
8
+ /** Section icon (shown before the label). */
9
+ icon?: string;
10
+ /** Section content (`TreeListItem` elements). */
11
+ children?: JSXElement;
12
+ /** Whether the filter hides every tree item of the section (internal). */
13
+ hidden?: boolean;
14
+ /** ref to the root `<li>` element. */
15
+ ref?: CommonRef;
16
+ }
17
+ /**
18
+ * Props that React/Vue wrappers need to re-declare with framework-specific types.
19
+ */
20
+ export type TreeListSectionPropsToOverride = 'label' | 'children';
21
+ /**
22
+ * Injected framework-specific components for TreeListSection rendering.
23
+ */
24
+ export interface TreeListSectionComponents {
25
+ /** ListSection component (framework-specific). */
26
+ ListSection: any;
27
+ }
28
+ /**
29
+ * Component display name.
30
+ */
31
+ export declare const COMPONENT_NAME = "TreeListSection";
32
+ /**
33
+ * Component default class name and class prefix.
34
+ */
35
+ export declare const CLASSNAME: LumxClassName<typeof COMPONENT_NAME>;
36
+ /**
37
+ * TreeListSection core template: a section of root tree items in a `TreeList`, with an optional label. The
38
+ * list sections get a divider between them (and between them and the standalone tree items).
39
+ *
40
+ * The section has no ARIA semantics (`role="none"` on the `<li>` and on the `<ul>`): in a tree, a
41
+ * `role="group"` is the group of sub-items of a tree item, and it changes the level of its tree items. The
42
+ * tree items of a section stay root tree items (`aria-level` 1).
43
+ *
44
+ * @param props Component props.
45
+ * @param components Injected framework-specific components.
46
+ * @return JSX element.
47
+ */
48
+ export declare const TreeListSection: {
49
+ (props: TreeListSectionProps, { ListSection }: TreeListSectionComponents): import("react").JSX.Element;
50
+ displayName: string;
51
+ className: "lumx-tree-list-section";
52
+ };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Tree items that can become active: not inside a hidden ancestor (a closed group, or a tree item
3
+ * hidden by the filter). The selector tree walker does not skip hidden subtrees, so the selector does.
4
+ */
5
+ export declare const TREE_ITEM_SELECTOR = "[role=\"treeitem\"]:not([hidden] *)";
6
+ /** Attribute of the elements that hold the own text of a tree item (its label and description). */
7
+ export declare const TREE_LABEL_ATTRIBUTE = "data-tree-label";
8
+ /** Attribute of the expand toggles: `TREE_MAIN_TOGGLE_VALUE` when the toggle is the main action of the row, else empty. */
9
+ export declare const TREE_TOGGLE_ATTRIBUTE = "data-tree-toggle";
10
+ /** Value of `TREE_TOGGLE_ATTRIBUTE` on the expand toggle that is the main action of the row. */
11
+ export declare const TREE_MAIN_TOGGLE_VALUE = "main";
12
+ /** The expand toggles (their mousedown must not move DOM focus). */
13
+ export declare const TREE_TOGGLE_SELECTOR = "[data-tree-toggle]";
14
+ /**
15
+ * The expand toggle of a non-selectable parent item: the main action of the row (its overlay covers the row
16
+ * and catches the clicks on the tree item).
17
+ */
18
+ export declare const TREE_MAIN_TOGGLE_SELECTOR = "[data-tree-toggle=\"main\"]";
19
+ /** Get the ID of the group of sub-items of a tree item. */
20
+ export declare const getTreeListItemGroupId: (id: string) => string;
21
+ /** Get the ID of the label of a tree item. */
22
+ export declare const getTreeListItemLabelId: (id: string) => string;
23
+ /** Get the ID of the description of a tree item. */
24
+ export declare const getTreeListItemDescriptionId: (id: string) => string;
25
+ /** CSS custom property set on each group: the nesting level of its sub-items (the indent). */
26
+ export declare const TREE_LEVEL_PROPERTY = "--lumx-tree-list-level";
27
+ /** The root of the tree item that contains an element (a tree item element, an expand toggle, a group…). */
28
+ export declare const getTreeItemRoot: (target: Element) => HTMLElement | null;
29
+ /** The tree item element of a tree item root (the row comes before the group: it is the first one). */
30
+ export declare const getTreeItemOfRoot: (root: HTMLElement) => HTMLElement | null;
31
+ /** The group of a tree item root (null on a leaf item). */
32
+ export declare const getGroupOfRoot: (root: HTMLElement) => HTMLElement | null;
33
+ /** The root of the parent item of a tree item root (null for a root tree item). */
34
+ export declare function getParentRoot(root: HTMLElement): HTMLElement | null;
35
+ /** Find the parent item of a tree item element, inside the tree element. Returns null for a root tree item. */
36
+ export declare function getParentTreeItem(container: HTMLElement, item: HTMLElement): HTMLElement | null;
37
+ /** The first sub-item of a tree item element that can become active (null on a leaf item or a closed group). */
38
+ export declare function getFirstSubItem(item: HTMLElement): HTMLElement | null;
39
+ /**
40
+ * The open state of a tree item element in the DOM: undefined on a leaf item (no `aria-expanded`). (The tree
41
+ * item registry holds the open state: this is the fallback for a tree item that is not registered.)
42
+ */
43
+ export declare function isTreeItemOpen(item: HTMLElement): boolean | undefined;
44
+ /**
45
+ * Write the open state of a parent item to the DOM, before the framework renders it: Up/Down select the tree
46
+ * items that can become active from the DOM (not in a `hidden` group), and they can run before the next render.
47
+ */
48
+ export declare function writeTreeItemOpen(root: HTMLElement, isOpen: boolean): void;
49
+ /**
50
+ * The own text of a tree item root: its label and description, never the text of its sub-items. Only the row is
51
+ * read (the children of the root other than the group), so the cost does not depend on the number of sub-items.
52
+ */
53
+ export declare function getTreeItemText(root: HTMLElement): string;
54
+ /** Whether a sub-item at any depth of a tree item root is selected. */
55
+ export declare const hasSelectedSubItem: (root: HTMLElement) => boolean;
56
+ /**
57
+ * Keep `aria-busy` on the group of a tree item root while the group holds skeletons and no sub-item.
58
+ * Observes the direct children only: the root (the group appears or goes) and the group (the skeletons and the
59
+ * sub-item roots, inserted with their content). Returns the function that stops the observation.
60
+ */
61
+ export declare function observeGroupBusy(root: HTMLElement): () => void;
@@ -0,0 +1,11 @@
1
+ export { setupTreeList } from './setupTreeList';
2
+ export type { TreeListHandle, TreeListOptions, TreeListItemController, TreeListItemOptions, TreeListItemState, TreeListSectionState, } from './types';
3
+ export { isTreeListHandle } from './utils';
4
+ export { isTreeValueSelected, toggleTreeValue } from './selection';
5
+ export type { TreeListSelectionType } from './selection';
6
+ export { TreeList } from './TreeList';
7
+ export type { TreeListProps } from './TreeList';
8
+ export { TreeListItem } from './TreeListItem';
9
+ export type { TreeListItemProps, TreeListItemPropsToOverride, TreeListItemComponents } from './TreeListItem';
10
+ export { TreeListSection } from './TreeListSection';
11
+ export type { TreeListSectionProps, TreeListSectionPropsToOverride, TreeListSectionComponents, } from './TreeListSection';
@@ -0,0 +1,15 @@
1
+ import type { CompositeNavigation, CompositeNavigationOptions } from '../Composite/types';
2
+ /** What the tree navigation reads and requests through the tree item registry. */
3
+ export interface TreeNavigationRegistry {
4
+ /** The open state of a tree item element (undefined on a leaf item). */
5
+ getOpenState(item: HTMLElement): boolean | undefined;
6
+ /** Open or close the parent item of a tree item element. */
7
+ openTreeItem(item: HTMLElement, isOpen: boolean): void;
8
+ }
9
+ /**
10
+ * Navigation module for the tree pattern (`role="tree"` with `role="treeitem"` items, sub-items in `role="group"`).
11
+ * Up/Down move over the visible tree items (the ones inside a closed parent item are skipped).
12
+ * Right/Left open and close the parent items (through the tree item registry, which holds the open state), or
13
+ * move to the first sub-item and to the parent item.
14
+ */
15
+ export declare function createTreeNavigation(options: CompositeNavigationOptions, { getOpenState, openTreeItem }: TreeNavigationRegistry): CompositeNavigation;
@@ -0,0 +1,9 @@
1
+ /** Selection type of a tree list: one selected value, or several. */
2
+ export type TreeListSelectionType = 'single' | 'multiple';
3
+ /** Whether a tree item value is selected (in the tree value, or equal to it). */
4
+ export declare function isTreeValueSelected(value: string | string[] | undefined, itemValue: string): boolean;
5
+ /**
6
+ * Next value of a multiple selection tree after the user selects a tree item: the item value is removed
7
+ * when it is selected, else added. Pure function: never mutates `value`.
8
+ */
9
+ export declare function toggleTreeValue(value: string[] | undefined, itemValue: string): string[];
@@ -0,0 +1,18 @@
1
+ import type { TreeListHandle, TreeListOptions } from './types';
2
+ /**
3
+ * Set up tree list behavior (WAI-ARIA tree pattern) independent of any DOM element.
4
+ *
5
+ * Built on the composite base (see {@link setupComposite}: focus owner, focus navigation, keyboard,
6
+ * selection, open state, skeletons, loading announcement and events). The tree list adds the tree item
7
+ * registry (the open state and the filter state of each tree item, see
8
+ * {@link TreeListHandle.registerTreeItem}), the tree filter and the tree navigation (Right and Left open
9
+ * and close the parent items through the registry).
10
+ *
11
+ * - Standalone (no `focusOwner` option): the tree element owns DOM focus and `aria-activedescendant`,
12
+ * and handles its own keyboard navigation. It has no filter.
13
+ * - Linked (`focusOwner` option, e.g. a combobox trigger): the parent owns focus and the keyboard; the
14
+ * tree writes `aria-activedescendant` on the parent focus owner. The trigger input sets the filter.
15
+ *
16
+ * @see https://www.w3.org/WAI/ARIA/apg/patterns/treeview/
17
+ */
18
+ export declare function setupTreeList(options?: TreeListOptions): TreeListHandle;
@@ -0,0 +1,65 @@
1
+ import type { CompositeHandle, CompositeOptions } from '../Composite/types';
2
+ /**
3
+ * Options of {@link setupTreeList} (the composite options).
4
+ * Without `focusOwner`, the tree is standalone: it owns focus and it has no filter.
5
+ */
6
+ export type TreeListOptions = CompositeOptions;
7
+ /** State of a tree item, rendered by the tree item components. */
8
+ export interface TreeListItemState {
9
+ /** Whether the parent item is open (always false on a leaf item). */
10
+ isOpen: boolean;
11
+ /** Whether the filter hides the tree item. */
12
+ hidden: boolean;
13
+ }
14
+ /** Options of {@link TreeListHandle.registerTreeItem}. */
15
+ export interface TreeListItemOptions {
16
+ /** Whether the tree item is a parent item (it has sub-items, or it loads them on open). */
17
+ isParent(): boolean;
18
+ /** Called on every open and close by the user (never for the initial state or for the filter). */
19
+ onOpenChange?(isOpen: boolean): void;
20
+ /** Called when the state changes. */
21
+ onChange(state: TreeListItemState): void;
22
+ }
23
+ /** State of a section, rendered by the section components. */
24
+ export interface TreeListSectionState {
25
+ /** Whether the filter hides every tree item of the section (a section with no tree item stays visible). */
26
+ hidden: boolean;
27
+ }
28
+ /** Controller of a registered tree item (see {@link TreeListHandle.registerTreeItem}). */
29
+ export interface TreeListItemController {
30
+ /** The current state. */
31
+ readonly state: TreeListItemState;
32
+ /** Open or close the parent item (a user action: fires `onOpenChange`). Does nothing on a leaf item. */
33
+ setOpen(isOpen: boolean): void;
34
+ /** Toggle the parent item (a user action). */
35
+ toggle(): void;
36
+ /** Unregister the tree item and remove the listeners. */
37
+ destroy(): void;
38
+ }
39
+ /**
40
+ * Handle returned by {@link setupTreeList}: the composite handle (WAI-ARIA tree pattern), plus the
41
+ * tree item registry.
42
+ */
43
+ export interface TreeListHandle extends CompositeHandle {
44
+ /**
45
+ * Register a tree item root `<li>` element (what the React and Vue tree item components do on mount), and
46
+ * get the controller of its open state. The tree item matches the filter on its own text (its
47
+ * `[data-tree-label]` elements), never on its sub-items.
48
+ *
49
+ * The open state is internal to the controller:
50
+ * - Initial state: open when a sub-item at any depth is selected (the closed groups stay mounted).
51
+ * - Without a filter: the user state (toggle, Right, Left, a click on a non-selectable parent item…).
52
+ * - During a filter: the parent items with a match below open. A user action lasts until the next
53
+ * change of the filter text. On clear, each parent item goes back to its state from before the
54
+ * filter, and the ancestors of the selected items stay open.
55
+ * - On close, an active item inside the group moves to this tree item.
56
+ *
57
+ * The registry also sets `aria-busy` on the group while it holds only skeletons.
58
+ */
59
+ registerTreeItem(element: HTMLElement, options: TreeListItemOptions): TreeListItemController;
60
+ /**
61
+ * Register a section root `<li>` element (what the React and Vue section components do on mount). `onChange`
62
+ * is called at once with the current state, then on each change. Returns the function that unregisters it.
63
+ */
64
+ registerSection(element: HTMLElement, onChange: (state: TreeListSectionState) => void): () => void;
65
+ }
@@ -0,0 +1,4 @@
1
+ import type { CompositeHandle } from '../Composite/types';
2
+ import type { TreeListHandle } from './types';
3
+ /** Whether a composite handle is a tree list handle (it has the tree item registry). */
4
+ export declare function isTreeListHandle(handle: CompositeHandle | null | undefined): handle is TreeListHandle;
@@ -0,0 +1,2 @@
1
+ /** Whether a text contains a search text, with no regard to the letter case (an empty search text always matches). */
2
+ export declare function includesIgnoreCase(text: string, search: string): boolean;
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:not(:has(:is([role=listbox], [role=grid]):not([hidden]), .lumx-composite-status)) {
5724
+ .lumx-combobox-popover:not(:has(:is([role=listbox], [role=grid], [role=tree]):not([hidden]), .lumx-composite-status)) {
5725
5725
  display: none;
5726
5726
  }
5727
5727
 
@@ -9021,7 +9021,7 @@ table {
9021
9021
 
9022
9022
  /* Section
9023
9023
  ========================================================================== */
9024
- .lumx-list-section:not([hidden]) ~ .lumx-list-section:not(.lumx-list-section:not([hidden]) + .lumx-list-section):not(.lumx-list-divider + .lumx-list-section)::before {
9024
+ :not(.lumx-list-divider, [hidden], :empty) ~ .lumx-list-section:not(.lumx-list-section:not([hidden]) + .lumx-list-section):not(.lumx-list-divider + .lumx-list-section)::before {
9025
9025
  content: "";
9026
9026
  display: block;
9027
9027
  height: 1px;
@@ -12987,6 +12987,87 @@ table {
12987
12987
  user-select: none;
12988
12988
  }
12989
12989
 
12990
+ /* ==========================================================================
12991
+ Tree list
12992
+ ========================================================================== */
12993
+ .lumx-tree-list:empty {
12994
+ display: none;
12995
+ }
12996
+
12997
+ .lumx-tree-list-item__row {
12998
+ padding-left: calc(var(--lumx-tree-list-level, 0) * 16px);
12999
+ }
13000
+ .lumx-tree-list-item__row > .lumx-list-item__wrapper > .lumx-list-item__content {
13001
+ min-width: 0;
13002
+ }
13003
+ .lumx-tree-list-item__row > .lumx-list-item__wrapper > .lumx-list-item__before {
13004
+ justify-content: flex-start;
13005
+ width: auto;
13006
+ }
13007
+ .lumx-tree-list-item__row .lumx-tree-list-item__action {
13008
+ display: block;
13009
+ width: 100%;
13010
+ }
13011
+ .lumx-tree-list-item__action--passive {
13012
+ pointer-events: none;
13013
+ }
13014
+ .lumx-tree-list-item__toggle, .lumx-tree-list-item__spacer {
13015
+ flex-shrink: 0;
13016
+ }
13017
+ .lumx-tree-list-item__spacer {
13018
+ width: calc(var(--lumx-button-height) / 1.5);
13019
+ }
13020
+ .lumx-tree-list-item__toggle {
13021
+ margin-block: calc((20px - calc(var(--lumx-button-height) / 1.5)) / 2);
13022
+ }
13023
+ .lumx-tree-list-item__toggle.lumx-button--size-s.lumx-button--variant-icon > i {
13024
+ width: 20px;
13025
+ height: 20px;
13026
+ font-size: 20px;
13027
+ line-height: 20px;
13028
+ }
13029
+ .lumx-tree-list-item__row .lumx-tree-list-item__toggle--main {
13030
+ position: static;
13031
+ }
13032
+ .lumx-tree-list-item__row .lumx-tree-list-item__toggle--main.lumx-button.lumx-action-area__action::before {
13033
+ pointer-events: auto;
13034
+ border-radius: 0;
13035
+ }
13036
+ .lumx-tree-list-item__row:has(.lumx-tree-list-item__action--passive[data-focus-visible-added]) .lumx-tree-list-item__toggle--main::before {
13037
+ background-color: var(--lumx-color-dark-L5);
13038
+ outline-style: solid;
13039
+ outline-offset: -2px;
13040
+ }
13041
+ .lumx-tree-list-item__row:has(.lumx-tree-list-item__action--passive[data-focus-visible-added]) .lumx-tree-list-item__toggle--main {
13042
+ color: var(--lumx-button-emphasis-low-state-hover-theme-light-color);
13043
+ background-color: var(--lumx-button-emphasis-low-state-hover-theme-light-background-color);
13044
+ }
13045
+ .lumx-tree-list-item__group {
13046
+ padding: 0;
13047
+ margin: 0;
13048
+ list-style: none;
13049
+ }
13050
+ .lumx-tree-list-item__group > :not(.lumx-tree-list-item) {
13051
+ margin-left: calc(var(--lumx-tree-list-level, 0) * 16px);
13052
+ }
13053
+ @supports (interpolate-size: allow-keywords) {
13054
+ .lumx-tree-list-item__group {
13055
+ interpolate-size: allow-keywords;
13056
+ overflow-y: clip;
13057
+ transition: height 400ms, content-visibility 400ms allow-discrete;
13058
+ }
13059
+ @media (prefers-reduced-motion: reduce) {
13060
+ .lumx-tree-list-item__group {
13061
+ transition: none;
13062
+ }
13063
+ }
13064
+ .lumx-tree-list-item__group[hidden] {
13065
+ display: block;
13066
+ height: 0;
13067
+ content-visibility: hidden;
13068
+ }
13069
+ }
13070
+
12990
13071
  /* ==========================================================================
12991
13072
  Uploader
12992
13073
  ========================================================================== */
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.27.1-alpha.3",
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.27.1-alpha.3",
70
70
  "devDependencies": {
71
71
  "@rollup/plugin-typescript": "^12.3.0",
72
72
  "@testing-library/dom": "^10.4.1",
@@ -89,6 +89,5 @@
89
89
  "vite": "^7.3.7",
90
90
  "vite-tsconfig-paths": "^5.1.4",
91
91
  "vitest": "^4.1.11"
92
- },
93
- "stableVersion": "4.27.0"
92
+ }
94
93
  }
@@ -55,5 +55,6 @@
55
55
  @import "./components/thumbnail/index";
56
56
  @import "./components/toolbar/index";
57
57
  @import "./components/tooltip/index";
58
+ @import "./components/tree-list/index";
58
59
  @import "./components/uploader/index";
59
60
  @import "./components/user-block/index";
@@ -23,7 +23,7 @@
23
23
 
24
24
  // Hide the popover when it holds no visible list (the composite sets `hidden` on a list without visible
25
25
  // content) and no state
26
- $visible-list: ':is([role="listbox"], [role="grid"]):not([hidden])';
26
+ $visible-list: ':is([role="listbox"], [role="grid"], [role="tree"]):not([hidden])';
27
27
 
28
28
  &:not(:has(#{$visible-list}, .#{$lumx-base-prefix}-composite-status)) {
29
29
  display: none;
@@ -148,9 +148,10 @@
148
148
  // Insert a divider before each section that:
149
149
  // 1. Is not directly following another visible section (avoids double dividers)
150
150
  // 2. Is not directly following an explicit divider
151
- // 3. Has at least one preceding visible section (uses `~` general sibling combinator
152
- // so hidden-first-sections don't get a spurious top divider)
153
- #{$section}:not([hidden]) ~ &:not(#{$section}:not([hidden]) + &):not(#{$divider} + &) {
151
+ // 3. Has visible content before it: a preceding sibling that is not an explicit divider, hidden or
152
+ // empty (uses `~` general sibling combinator so that a section with only hidden content before it
153
+ // does not get a top divider)
154
+ :not(#{$divider}, [hidden], :empty) ~ &:not(#{$section}:not([hidden]) + &):not(#{$divider} + &) {
154
155
  &::before {
155
156
  content: '';
156
157
  display: block;