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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/components-and-utils.css +93 -8
  2. package/js/components/Combobox/Tests.d.ts +5 -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 +55 -17
  8. package/js/components/Composite/CompositeItemDescription.d.ts +17 -0
  9. package/js/components/Composite/CompositeSelectionIcon.d.ts +20 -0
  10. package/js/components/Composite/CompositeStatus.d.ts +82 -0
  11. package/js/components/{Listbox → Composite}/constants.d.ts +3 -1
  12. package/js/components/Composite/index.d.ts +7 -0
  13. package/js/components/Composite/setupComposite.d.ts +28 -0
  14. package/js/components/Composite/types.d.ts +260 -0
  15. package/js/components/Composite/utils.d.ts +19 -0
  16. package/js/components/Listbox/ListboxSection.d.ts +1 -1
  17. package/js/components/Listbox/index.d.ts +2 -5
  18. package/js/components/Listbox/navigation.d.ts +3 -38
  19. package/js/components/Listbox/setupListbox.d.ts +6 -4
  20. package/js/components/Listbox/types.d.ts +6 -125
  21. package/js/components/Listbox/utils.d.ts +4 -28
  22. package/js/components/TreeList/Stories.d.ts +72 -0
  23. package/js/components/TreeList/TestStories.d.ts +88 -0
  24. package/js/components/TreeList/Tests.d.ts +49 -0
  25. package/js/components/TreeList/TreeList.d.ts +60 -0
  26. package/js/components/TreeList/TreeListItem.d.ts +84 -0
  27. package/js/components/TreeList/dom.d.ts +61 -0
  28. package/js/components/TreeList/index.d.ts +9 -0
  29. package/js/components/TreeList/navigation.d.ts +15 -0
  30. package/js/components/TreeList/selection.d.ts +9 -0
  31. package/js/components/TreeList/setupTreeList.d.ts +18 -0
  32. package/js/components/TreeList/types.d.ts +55 -0
  33. package/js/components/TreeList/utils.d.ts +4 -0
  34. package/js/utils/string/includesIgnoreCase.d.ts +2 -0
  35. package/lumx.css +93 -8
  36. package/package.json +2 -2
  37. package/scss/_components_classes.scss +2 -0
  38. package/scss/components/combobox/_index.scss +4 -4
  39. package/scss/components/composite/_index.scss +20 -0
  40. package/scss/components/list-box/_index.scss +2 -13
  41. package/scss/components/tree-list/_index.scss +144 -0
  42. package/scss/core/action-area/_index.scss +3 -4
  43. package/scss/core/action-area/_mixins.scss +11 -0
  44. package/js/components/Listbox/ListboxOptionSelectionIcon.d.ts +0 -13
  45. package/js/components/Listbox/ListboxState.d.ts +0 -105
  46. package/js/components/Listbox/subscribeListboxState.d.ts +0 -24
@@ -0,0 +1,88 @@
1
+ import type { SetupStoriesOptions } from '@lumx/core/stories/types';
2
+ import { type TreeListComponents } from './Tests';
3
+ export declare function setup({ components, decorators: { withValueOnChange }, }: SetupStoriesOptions<{
4
+ components: TreeListComponents;
5
+ decorators: 'withValueOnChange';
6
+ }>): {
7
+ meta: {
8
+ component: any;
9
+ };
10
+ TreeItemRowLayout: {
11
+ render: ({ value, onUpdate, onSelect, treeOnSelect, filter, selectionType, onOpenChange, onClick, nbOptionMessage, withoutState, snacks, }: any) => import("react").JSX.Element;
12
+ play(): Promise<void>;
13
+ args: {
14
+ value: {
15
+ text: string;
16
+ selected: string;
17
+ };
18
+ };
19
+ decorators: ((story: any, context: any) => any)[];
20
+ };
21
+ ClickNonSelectableParentItemRow: {
22
+ render: ({ value, onUpdate, onSelect, treeOnSelect, filter, selectionType, onOpenChange, onClick, nbOptionMessage, withoutState, snacks, }: any) => import("react").JSX.Element;
23
+ play(): Promise<void>;
24
+ args: {
25
+ value: {
26
+ text: string;
27
+ selected: string;
28
+ };
29
+ };
30
+ decorators: ((story: any, context: any) => any)[];
31
+ };
32
+ FilterNoMatchHidesPopover: {
33
+ args: {
34
+ withoutState: boolean;
35
+ snacks: string;
36
+ value: {
37
+ text: string;
38
+ selected: string;
39
+ };
40
+ };
41
+ render: ({ value, onUpdate, onSelect, treeOnSelect, filter, selectionType, onOpenChange, onClick, nbOptionMessage, withoutState, snacks, }: any) => import("react").JSX.Element;
42
+ play(): Promise<void>;
43
+ decorators: ((story: any, context: any) => any)[];
44
+ };
45
+ AccessibilityOpenTree: {
46
+ parameters: {
47
+ a11y: {
48
+ test: string;
49
+ };
50
+ };
51
+ render: ({ value, onUpdate, onSelect, treeOnSelect, filter, selectionType, onOpenChange, onClick, nbOptionMessage, withoutState, snacks, }: any) => import("react").JSX.Element;
52
+ play(): Promise<void>;
53
+ args: {
54
+ value: {
55
+ text: string;
56
+ selected: string;
57
+ };
58
+ };
59
+ decorators: ((story: any, context: any) => any)[];
60
+ };
61
+ AccessibilityLoadingGroup: {
62
+ args: {
63
+ value: string;
64
+ load: Promise<unknown>;
65
+ };
66
+ decorators: ((story: any, context: any) => any)[];
67
+ parameters: {
68
+ a11y: {
69
+ test: string;
70
+ };
71
+ };
72
+ render: ({ value, onChange, onOpenChange, load }: any) => import("react").JSX.Element;
73
+ play(): Promise<void>;
74
+ };
75
+ AccessibilityStandaloneTree: {
76
+ args: {
77
+ value: string;
78
+ };
79
+ decorators: ((story: any, context: any) => any)[];
80
+ parameters: {
81
+ a11y: {
82
+ test: string;
83
+ };
84
+ };
85
+ render: ({ value, onUpdate, onSelect, onOpenChange, onClick, selectionType }: any) => import("react").JSX.Element;
86
+ play(): Promise<void>;
87
+ };
88
+ };
@@ -0,0 +1,49 @@
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
+ Combobox: TreeListComboboxNamespace;
18
+ }
19
+ type RenderResult = {
20
+ unmount: () => void;
21
+ container: HTMLElement;
22
+ };
23
+ /**
24
+ * Options to set up the tree list test suite.
25
+ * Injected by the framework-specific test file (React or Vue).
26
+ */
27
+ export interface TreeListTestSetup {
28
+ components: TreeListComponents;
29
+ /**
30
+ * Render a template with controlled state management (one `value` state, set by the
31
+ * `onChangeProp` callback). Mirrors the withValueOnChange Storybook decorator.
32
+ */
33
+ renderWithState: (template: (props: any) => any, initialArgs?: Record<string, any>, options?: {
34
+ onChangeProp?: string;
35
+ valueExtract?: (v: any) => any;
36
+ }) => RenderResult;
37
+ }
38
+ /**
39
+ * Create framework-agnostic JSX templates for the tree tests (the reference tree of the spec).
40
+ * Exported so the test stories can reuse the same tree.
41
+ */
42
+ export declare function createTreeTemplates({ TreeList, TreeListItem, Combobox }: TreeListComponents): {
43
+ inputTemplate: ({ value, onUpdate, onSelect, treeOnSelect, filter, selectionType, onOpenChange, onClick, nbOptionMessage, withoutState, snacks, }: any) => import("react").JSX.Element;
44
+ buttonTemplate: ({ value, onSelect, onOpenChange }: any) => import("react").JSX.Element;
45
+ lazyTemplate: ({ value, onChange, onOpenChange, load }: any) => import("react").JSX.Element;
46
+ standaloneTemplate: ({ value, onUpdate, onSelect, onOpenChange, onClick, selectionType }: any) => import("react").JSX.Element;
47
+ };
48
+ export default function treeListTests({ components, renderWithState }: TreeListTestSetup): void;
49
+ 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`, `ListboxOptionSkeleton` or `CompositeStatus` elements). */
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`, `ListboxOptionSkeleton` or `CompositeStatus` 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,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,9 @@
1
+ export { setupTreeList } from './setupTreeList';
2
+ export type { TreeListHandle, TreeListOptions, TreeListItemController, TreeListItemOptions, TreeListItemState, } 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';
@@ -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,55 @@
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
+ /** Controller of a registered tree item (see {@link TreeListHandle.registerTreeItem}). */
24
+ export interface TreeListItemController {
25
+ /** The current state. */
26
+ readonly state: TreeListItemState;
27
+ /** Open or close the parent item (a user action: fires `onOpenChange`). Does nothing on a leaf item. */
28
+ setOpen(isOpen: boolean): void;
29
+ /** Toggle the parent item (a user action). */
30
+ toggle(): void;
31
+ /** Unregister the tree item and remove the listeners. */
32
+ destroy(): void;
33
+ }
34
+ /**
35
+ * Handle returned by {@link setupTreeList}: the composite handle (WAI-ARIA tree pattern), plus the
36
+ * tree item registry.
37
+ */
38
+ export interface TreeListHandle extends CompositeHandle {
39
+ /**
40
+ * Register a tree item root `<li>` element (what the React and Vue tree item components do on mount), and
41
+ * get the controller of its open state. The tree item matches the filter on its own text (its
42
+ * `[data-tree-label]` elements), never on its sub-items.
43
+ *
44
+ * The open state is internal to the controller:
45
+ * - Initial state: open when a sub-item at any depth is selected (the closed groups stay mounted).
46
+ * - Without a filter: the user state (toggle, Right, Left, a click on a non-selectable parent item…).
47
+ * - During a filter: the parent items with a match below open. A user action lasts until the next
48
+ * change of the filter text. On clear, each parent item goes back to its state from before the
49
+ * filter, and the ancestors of the selected items stay open.
50
+ * - On close, an active item inside the group moves to this tree item.
51
+ *
52
+ * The registry also sets `aria-busy` on the group while it holds only skeletons.
53
+ */
54
+ registerTreeItem(element: HTMLElement, options: TreeListItemOptions): TreeListItemController;
55
+ }
@@ -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-listbox-state)) {
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
 
@@ -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
  ========================================================================== */
@@ -8101,10 +8112,6 @@ table {
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;
@@ -12983,6 +12987,87 @@ table {
12983
12987
  user-select: none;
12984
12988
  }
12985
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, visibility 400ms;
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
+ visibility: hidden;
13068
+ }
13069
+ }
13070
+
12986
13071
  /* ==========================================================================
12987
13072
  Uploader
12988
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.0",
10
+ "@lumx/icons": "^4.27.1-alpha.2",
11
11
  "classnames": "^2.3.2",
12
12
  "focus-visible": "^5.0.2",
13
13
  "lodash": "4.18.1",
@@ -66,7 +66,7 @@
66
66
  "update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
67
67
  },
68
68
  "sideEffects": false,
69
- "version": "4.27.1-alpha.0",
69
+ "version": "4.27.1-alpha.2",
70
70
  "devDependencies": {
71
71
  "@rollup/plugin-typescript": "^12.3.0",
72
72
  "@testing-library/dom": "^10.4.1",
@@ -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";
@@ -54,5 +55,6 @@
54
55
  @import "./components/thumbnail/index";
55
56
  @import "./components/toolbar/index";
56
57
  @import "./components/tooltip/index";
58
+ @import "./components/tree-list/index";
57
59
  @import "./components/uploader/index";
58
60
  @import "./components/user-block/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 the popover when it holds no visible list (the listbox sets `hidden` on a list without visible
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
- &:not(:has(#{$visible-list}, .#{$lumx-base-prefix}-listbox-state)) {
28
+ &:not(:has(#{$visible-list}, .#{$lumx-base-prefix}-composite-status)) {
29
29
  display: none;
30
30
  }
31
31
  }