@angular/aria 21.0.4 → 21.0.6

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.
@@ -110,13 +110,14 @@ declare class ListTypeahead<T extends ListTypeaheadItem> {
110
110
  }
111
111
 
112
112
  /** The operations that the list can perform after navigation. */
113
- interface NavOptions {
113
+ interface NavOptions<T = any> {
114
114
  toggle?: boolean;
115
115
  select?: boolean;
116
116
  selectOne?: boolean;
117
117
  selectRange?: boolean;
118
118
  anchor?: boolean;
119
119
  focusElement?: boolean;
120
+ items?: T[];
120
121
  }
121
122
  /** Represents an item in the list. */
122
123
  type ListItem<V> = ListTypeaheadItem & ListNavigationItem & ListSelectionItem<V> & ListFocusItem;
@@ -160,15 +161,15 @@ declare class List<T extends ListItem<V>, V> {
160
161
  /** Returns the tab index for the given item. */
161
162
  getItemTabindex(item: T): 0 | -1;
162
163
  /** Navigates to the first option in the list. */
163
- first(opts?: NavOptions): void;
164
+ first(opts?: NavOptions<T>): void;
164
165
  /** Navigates to the last option in the list. */
165
- last(opts?: NavOptions): void;
166
+ last(opts?: NavOptions<T>): void;
166
167
  /** Navigates to the next option in the list. */
167
- next(opts?: NavOptions): void;
168
+ next(opts?: NavOptions<T>): void;
168
169
  /** Navigates to the previous option in the list. */
169
- prev(opts?: NavOptions): void;
170
+ prev(opts?: NavOptions<T>): void;
170
171
  /** Navigates to the given item in the list. */
171
- goto(item: T, opts?: NavOptions): void;
172
+ goto(item: T, opts?: NavOptions<T>): void;
172
173
  /** Removes focus from the list. */
173
174
  unfocus(): void;
174
175
  /** Marks the given index as the potential start of a range selection. */
@@ -207,5 +208,5 @@ declare class List<T extends ListItem<V>, V> {
207
208
  private _navigate;
208
209
  }
209
210
 
210
- export { List };
211
- export type { ListInputs, ListItem };
211
+ export { List, ListSelection, ListTypeahead };
212
+ export type { ListInputs, ListItem, ListSelectionInputs, ListSelectionItem, ListTypeaheadInputs, ListTypeaheadItem, NavOptions };
@@ -33,6 +33,7 @@ interface ListFocusInputs<T extends ListFocusItem> {
33
33
  activeItem: WritableSignalLike<T | undefined>;
34
34
  /** Whether disabled items in the list should be focusable. */
35
35
  softDisabled: SignalLike<boolean>;
36
+ /** The html element that should receive focus. */
36
37
  element: SignalLike<HTMLElement | undefined>;
37
38
  }
38
39
  /** Controls focus for a list of items. */
@@ -73,6 +74,19 @@ interface ListNavigationInputs<T extends ListNavigationItem> extends ListFocusIn
73
74
  /** The direction that text is read based on the users locale. */
74
75
  textDirection: SignalLike<'rtl' | 'ltr'>;
75
76
  }
77
+ /** Options for list navigation. */
78
+ interface ListNavigationOpts<T> {
79
+ /**
80
+ * Whether to focus the item's element.
81
+ * Defaults to true.
82
+ */
83
+ focusElement?: boolean;
84
+ /**
85
+ * The list of items to navigate through.
86
+ * Defaults to the list of items from the inputs.
87
+ */
88
+ items?: T[];
89
+ }
76
90
  /** Controls navigation for a list of items. */
77
91
  declare class ListNavigation<T extends ListNavigationItem> {
78
92
  readonly inputs: ListNavigationInputs<T> & {
@@ -82,33 +96,23 @@ declare class ListNavigation<T extends ListNavigationItem> {
82
96
  focusManager: ListFocus<T>;
83
97
  });
84
98
  /** Navigates to the given item. */
85
- goto(item?: T, opts?: {
86
- focusElement?: boolean;
87
- }): boolean;
99
+ goto(item?: T, opts?: ListNavigationOpts<T>): boolean;
88
100
  /** Navigates to the next item in the list. */
89
- next(opts?: {
90
- focusElement?: boolean;
91
- }): boolean;
101
+ next(opts?: ListNavigationOpts<T>): boolean;
92
102
  /** Peeks the next item in the list. */
93
- peekNext(): T | undefined;
103
+ peekNext(opts?: ListNavigationOpts<T>): T | undefined;
94
104
  /** Navigates to the previous item in the list. */
95
- prev(opts?: {
96
- focusElement?: boolean;
97
- }): boolean;
105
+ prev(opts?: ListNavigationOpts<T>): boolean;
98
106
  /** Peeks the previous item in the list. */
99
- peekPrev(): T | undefined;
107
+ peekPrev(opts?: ListNavigationOpts<T>): T | undefined;
100
108
  /** Navigates to the first item in the list. */
101
- first(opts?: {
102
- focusElement?: boolean;
103
- }): boolean;
109
+ first(opts?: ListNavigationOpts<T>): boolean;
104
110
  /** Navigates to the last item in the list. */
105
- last(opts?: {
106
- focusElement?: boolean;
107
- }): boolean;
111
+ last(opts?: ListNavigationOpts<T>): boolean;
108
112
  /** Gets the first focusable item from the given list of items. */
109
- peekFirst(items?: T[]): T | undefined;
113
+ peekFirst(opts?: ListNavigationOpts<T>): T | undefined;
110
114
  /** Gets the last focusable item from the given list of items. */
111
- peekLast(items?: T[]): T | undefined;
115
+ peekLast(opts?: ListNavigationOpts<T>): T | undefined;
112
116
  /** Advances to the next or previous focusable item in the list based on the given delta. */
113
117
  private _advance;
114
118
  /** Peeks the next or previous focusable item in the list based on the given delta. */
@@ -1,24 +1,127 @@
1
- import { SignalLike, WritableSignalLike } from './_list-navigation-chunk.js';
2
- import { ListItem, ListInputs, List } from './_list-chunk.js';
3
- import { ExpansionItem, ListExpansion } from './_expansion-chunk.js';
1
+ import { ListNavigationItem, ListFocusItem, SignalLike, ListFocusInputs, ListNavigationInputs, ListNavigation, ListFocus, WritableSignalLike } from './_list-navigation-chunk.js';
2
+ import { ExpansionItem, ListExpansionInputs, ListExpansion } from './_expansion-chunk.js';
3
+ import { ListTypeaheadItem, ListSelectionItem, ListSelectionInputs, ListTypeaheadInputs, ListSelection, ListTypeahead, NavOptions } from './_list-chunk.js';
4
4
  import { KeyboardEventManager } from './_keyboard-event-manager-chunk.js';
5
5
  import { PointerEventManager } from './_pointer-event-manager-chunk.js';
6
6
 
7
+ /** Represents an item in the tree. */
8
+ interface TreeItem<V, T extends TreeItem<V, T>> extends ListTypeaheadItem, ListNavigationItem, ListSelectionItem<V>, ListFocusItem, ExpansionItem {
9
+ /** The children of this item. */
10
+ children: SignalLike<T[] | undefined>;
11
+ /** The parent of this item. */
12
+ parent: SignalLike<T | undefined>;
13
+ /** Whether this item is visible. */
14
+ visible: SignalLike<boolean>;
15
+ }
16
+ /** The necessary inputs for the tree behavior. */
17
+ type TreeInputs$1<T extends TreeItem<V, T>, V> = ListFocusInputs<T> & ListNavigationInputs<T> & ListSelectionInputs<T, V> & ListTypeaheadInputs<T> & ListExpansionInputs;
18
+ /** Controls the state of a tree. */
19
+ declare class Tree<T extends TreeItem<V, T>, V> {
20
+ readonly inputs: TreeInputs$1<T, V>;
21
+ /** Controls navigation for the tree. */
22
+ navigationBehavior: ListNavigation<T>;
23
+ /** Controls selection for the tree. */
24
+ selectionBehavior: ListSelection<T, V>;
25
+ /** Controls typeahead for the tree. */
26
+ typeaheadBehavior: ListTypeahead<T>;
27
+ /** Controls focus for the tree. */
28
+ focusBehavior: ListFocus<T>;
29
+ /** Controls expansion for the tree. */
30
+ expansionBehavior: ListExpansion;
31
+ /** Whether the tree is disabled. */
32
+ disabled: SignalLike<boolean>;
33
+ /** The id of the current active item. */
34
+ activeDescendant: SignalLike<string | undefined>;
35
+ /** The tab index of the tree. */
36
+ tabIndex: SignalLike<0 | -1>;
37
+ /** The index of the currently active item in the tree (within the flattened list). */
38
+ activeIndex: SignalLike<number>;
39
+ /** The uncommitted index for selecting a range of options. */
40
+ private _anchorIndex;
41
+ /** Whether the list should wrap. */
42
+ private _wrap;
43
+ constructor(inputs: TreeInputs$1<T, V>);
44
+ /** Returns the tab index for the given item. */
45
+ getItemTabindex(item: T): 0 | -1;
46
+ /** Navigates to the first option in the tree. */
47
+ first(opts?: NavOptions<T>): void;
48
+ /** Navigates to the last option in the tree. */
49
+ last(opts?: NavOptions<T>): void;
50
+ /** Navigates to the next option in the tree. */
51
+ next(opts?: NavOptions<T>): void;
52
+ /** Navigates to the previous option in the tree. */
53
+ prev(opts?: NavOptions<T>): void;
54
+ /** Navigates to the first child of the current active item. */
55
+ firstChild(opts?: NavOptions<T>): void;
56
+ /** Navigates to the last child of the current active item. */
57
+ lastChild(opts?: NavOptions<T>): void;
58
+ /** Navigates to the next sibling of the current active item. */
59
+ nextSibling(opts?: NavOptions<T>): void;
60
+ /** Navigates to the previous sibling of the current active item. */
61
+ prevSibling(opts?: NavOptions<T>): void;
62
+ /** Navigates to the parent of the current active item. */
63
+ parent(opts?: NavOptions<T>): void;
64
+ /** Navigates to the given item in the tree. */
65
+ goto(item: T, opts?: NavOptions<T>): void;
66
+ /** Removes focus from the tree. */
67
+ unfocus(): void;
68
+ /** Marks the given index as the potential start of a range selection. */
69
+ anchor(index: number): void;
70
+ /** Handles typeahead search navigation for the tree. */
71
+ search(char: string, opts?: NavOptions<T>): void;
72
+ /** Checks if the tree is currently typing for typeahead search. */
73
+ isTyping(): boolean;
74
+ /** Selects the currently active item in the tree. */
75
+ select(item?: T): void;
76
+ /** Sets the selection to only the current active item. */
77
+ selectOne(): void;
78
+ /** Deselects the currently active item in the tree. */
79
+ deselect(item?: T): void;
80
+ /** Deselects all items in the tree. */
81
+ deselectAll(): void;
82
+ /** Toggles the currently active item in the tree. */
83
+ toggle(item?: T): void;
84
+ /** Toggles the currently active item in the tree, deselecting all other items. */
85
+ toggleOne(): void;
86
+ /** Toggles the selection of all items in the tree. */
87
+ toggleAll(): void;
88
+ /** Toggles the expansion of the given item. */
89
+ toggleExpansion(item?: T): void;
90
+ /** Expands the given item. */
91
+ expand(item: T): void;
92
+ /** Collapses the given item. */
93
+ collapse(item: T): void;
94
+ /** Expands all sibling items of the given item (or active item). */
95
+ expandSiblings(item?: T): void;
96
+ /** Expands all items in the tree. */
97
+ expandAll(): void;
98
+ /** Collapses all items in the tree. */
99
+ collapseAll(): void;
100
+ /** Checks if the given item is able to receive focus. */
101
+ isFocusable(item: T): boolean;
102
+ /** Checks if the given item is expandable. */
103
+ isExpandable(item: T): boolean;
104
+ /** Handles updating selection for the tree. */
105
+ updateSelection(opts?: NavOptions<T>): void;
106
+ /**
107
+ * Safely performs a navigation operation.
108
+ */
109
+ private _navigate;
110
+ }
111
+
7
112
  /** Represents the required inputs for a tree item. */
8
- interface TreeItemInputs<V> extends Omit<ListItem<V>, 'index'>, Omit<ExpansionItem, 'expandable'> {
113
+ interface TreeItemInputs<V> extends Omit<TreeItem<V, TreeItemPattern<V>>, 'index' | 'parent' | 'visible' | 'expandable'> {
9
114
  /** The parent item. */
10
115
  parent: SignalLike<TreeItemPattern<V> | TreePattern<V>>;
11
116
  /** Whether this item has children. Children can be lazily loaded. */
12
117
  hasChildren: SignalLike<boolean>;
13
- /** The children items. */
14
- children: SignalLike<TreeItemPattern<V>[]>;
15
118
  /** The tree pattern this item belongs to. */
16
119
  tree: SignalLike<TreePattern<V>>;
17
120
  }
18
121
  /**
19
122
  * Represents an item in a Tree.
20
123
  */
21
- declare class TreeItemPattern<V> implements ListItem<V>, ExpansionItem {
124
+ declare class TreeItemPattern<V> implements TreeItem<V, TreeItemPattern<V>> {
22
125
  readonly inputs: TreeItemInputs<V>;
23
126
  /** A unique identifier for this item. */
24
127
  readonly id: SignalLike<string>;
@@ -33,13 +136,11 @@ declare class TreeItemPattern<V> implements ListItem<V>, ExpansionItem {
33
136
  /** The tree pattern this item belongs to. */
34
137
  readonly tree: SignalLike<TreePattern<V>>;
35
138
  /** The parent item. */
36
- readonly parent: SignalLike<TreeItemPattern<V> | TreePattern<V>>;
139
+ readonly parent: SignalLike<TreeItemPattern<V> | undefined>;
37
140
  /** The children items. */
38
141
  readonly children: SignalLike<TreeItemPattern<V>[]>;
39
142
  /** The position of this item among its siblings. */
40
143
  readonly index: SignalLike<number>;
41
- /** Controls expansion for child items. */
42
- readonly expansionBehavior: ListExpansion;
43
144
  /** Whether the item is expandable. It's expandable if children item exist. */
44
145
  readonly expandable: SignalLike<boolean>;
45
146
  /** Whether the item is selectable. */
@@ -72,11 +173,9 @@ interface SelectOptions {
72
173
  anchor?: boolean;
73
174
  }
74
175
  /** Represents the required inputs for a tree. */
75
- interface TreeInputs<V> extends Omit<ListInputs<TreeItemPattern<V>, V>, 'items'> {
176
+ interface TreeInputs<V> extends Omit<TreeInputs$1<TreeItemPattern<V>, V>, 'multiExpandable'> {
76
177
  /** A unique identifier for the tree. */
77
178
  id: SignalLike<string>;
78
- /** All items in the tree, in document order (DFS-like, a flattened list). */
79
- allItems: SignalLike<TreeItemPattern<V>[]>;
80
179
  /** Whether the tree is in navigation mode. */
81
180
  nav: SignalLike<boolean>;
82
181
  /** The aria-current type. */
@@ -85,10 +184,8 @@ interface TreeInputs<V> extends Omit<ListInputs<TreeItemPattern<V>, V>, 'items'>
85
184
  /** Controls the state and interactions of a tree view. */
86
185
  declare class TreePattern<V> implements TreeInputs<V> {
87
186
  readonly inputs: TreeInputs<V>;
88
- /** The list behavior for the tree. */
89
- readonly listBehavior: List<TreeItemPattern<V>, V>;
90
- /** Controls expansion for direct children of the tree root (top-level items). */
91
- readonly expansionBehavior: ListExpansion;
187
+ /** The tree behavior for the tree. */
188
+ readonly treeBehavior: Tree<TreeItemPattern<V>, V>;
92
189
  /** The root level is 0. */
93
190
  readonly level: () => number;
94
191
  /** The root is always expanded. */
@@ -101,8 +198,6 @@ declare class TreePattern<V> implements TreeInputs<V> {
101
198
  readonly activeDescendant: SignalLike<string | undefined>;
102
199
  /** The direct children of the root (top-level tree items). */
103
200
  readonly children: SignalLike<TreeItemPattern<V>[]>;
104
- /** All currently visible tree items. An item is visible if their parent is expanded. */
105
- readonly visibleItems: SignalLike<TreeItemPattern<V>[]>;
106
201
  /** Whether the tree selection follows focus. */
107
202
  readonly followFocus: SignalLike<boolean>;
108
203
  /** Whether the tree direction is RTL. */
@@ -132,7 +227,7 @@ declare class TreePattern<V> implements TreeInputs<V> {
132
227
  /** The aria-current type. */
133
228
  readonly currentType: SignalLike<'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false'>;
134
229
  /** All items in the tree, in document order (DFS-like, a flattened list). */
135
- readonly allItems: SignalLike<TreeItemPattern<V>[]>;
230
+ readonly items: SignalLike<TreeItemPattern<V>[]>;
136
231
  /** The focus strategy used by the tree. */
137
232
  readonly focusMode: SignalLike<'roving' | 'activedescendant'>;
138
233
  /** Whether the tree is disabled. */
@@ -169,14 +264,10 @@ declare class TreePattern<V> implements TreeInputs<V> {
169
264
  onPointerdown(event: PointerEvent): void;
170
265
  /** Navigates to the given tree item in the tree. */
171
266
  goto(e: PointerEvent, opts?: SelectOptions): void;
172
- /** Toggles to expand or collapse a tree item. */
173
- toggleExpansion(item?: TreeItemPattern<V>): void;
174
- /** Expands a tree item. */
175
- expand(opts?: SelectOptions): void;
176
- /** Expands all sibling tree items including itself. */
177
- expandSiblings(item?: TreeItemPattern<V>): void;
178
- /** Collapses a tree item. */
179
- collapse(opts?: SelectOptions): void;
267
+ /** Expands the active item if possible, otherwise navigates to the first child. */
268
+ _expandOrFirstChild(opts?: SelectOptions): void;
269
+ /** Collapses the active item if possible, otherwise navigates to the parent. */
270
+ _collapseOrParent(opts?: SelectOptions): void;
180
271
  /** Retrieves the TreeItemPattern associated with a DOM event, if any. */
181
272
  protected _getItem(event: Event): TreeItemPattern<V> | undefined;
182
273
  }
@@ -199,4 +199,4 @@ declare class AccordionContent {
199
199
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<AccordionContent, "ng-template[ngAccordionContent]", never, {}, {}, never, never, true, [{ directive: typeof DeferredContent; inputs: {}; outputs: {}; }]>;
200
200
  }
201
201
 
202
- export { AccordionContent, AccordionGroup, AccordionPanel, AccordionTrigger, DeferredContent as ɵɵDeferredContent };
202
+ export { AccordionContent, AccordionGroup, AccordionPanel, AccordionTrigger, DeferredContent as ɵɵDeferredContent, DeferredContentAware as ɵɵDeferredContentAware };
package/types/menu.d.ts CHANGED
@@ -241,7 +241,7 @@ declare class MenuTrigger<V> {
241
241
  /** Closes the menu. */
242
242
  close(): void;
243
243
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<MenuTrigger<any>, never>;
244
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MenuTrigger<any>, "button[ngMenuTrigger]", ["ngMenuTrigger"], { "menu": { "alias": "menu"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "softDisabled": { "alias": "softDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
244
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<MenuTrigger<any>, "[ngMenuTrigger]", ["ngMenuTrigger"], { "menu": { "alias": "menu"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "softDisabled": { "alias": "softDisabled"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
245
245
  }
246
246
 
247
247
  /**
@@ -80,6 +80,8 @@ type ComboboxTreeInputs<V> = TreeInputs<V> & {
80
80
  };
81
81
  declare class ComboboxTreePattern<V> extends TreePattern<V> implements ComboboxTreeControls<TreeItemPattern<V>, V> {
82
82
  readonly inputs: ComboboxTreeInputs<V>;
83
+ /** Toggles to expand or collapse a tree item. */
84
+ toggleExpansion: (item?: TreeItemPattern<V>) => void;
83
85
  /** Whether the currently focused item is collapsible. */
84
86
  isItemCollapsible: () => boolean;
85
87
  /** The ARIA role for the tree. */
@@ -122,9 +124,9 @@ declare class ComboboxTreePattern<V> extends TreePattern<V> implements ComboboxT
122
124
  getSelectedItems: () => TreeItemPattern<V>[];
123
125
  /** Sets the value of the combobox tree. */
124
126
  setValue: (value: V | undefined) => void;
125
- /** Expands the currently focused item if it is expandable. */
127
+ /** Expands the currently focused item if it is expandable, or navigates to the first child. */
126
128
  expandItem: () => void;
127
- /** Collapses the currently focused item if it is expandable. */
129
+ /** Collapses the currently focused item if it is expandable, or navigates to the parent. */
128
130
  collapseItem: () => void;
129
131
  /** Whether the specified item or the currently active item is expandable. */
130
132
  isItemExpandable(item?: TreeItemPattern<V> | undefined): boolean;
package/types/tree.d.ts CHANGED
@@ -6,8 +6,8 @@ import { DeferredContent, DeferredContentAware } from './_deferred-content-chunk
6
6
  import { ComboboxPopup } from './combobox.js';
7
7
  export { Combobox as ɵɵCombobox, ComboboxDialog as ɵɵComboboxDialog, ComboboxInput as ɵɵComboboxInput, ComboboxPopupContainer as ɵɵComboboxPopupContainer } from './combobox.js';
8
8
  import './_list-navigation-chunk.js';
9
- import './_list-chunk.js';
10
9
  import './_expansion-chunk.js';
10
+ import './_list-chunk.js';
11
11
  import './_keyboard-event-manager-chunk.js';
12
12
  import './_pointer-event-manager-chunk.js';
13
13
  import './_combobox-chunk.js';