MCPcopy Index your code
hub / github.com/angular/components / TreePattern

Class TreePattern

src/aria/private/tree/tree.ts:150–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149/** Controls the state and interactions of a tree view. */
150export class TreePattern<V> implements TreeInputs<V> {
151 /** The tree behavior for the tree. */
152 readonly treeBehavior: Tree<TreeItemPattern<V>, V>;
153
154 /** Whether the tree has been interacted with. */
155 readonly hasBeenInteracted = signal(false);
156
157 /** The root level is 0. */
158 readonly level = () => 0;
159
160 /** The root is always expanded. */
161 readonly expanded = () => true;
162
163 /** The root is always visible. */
164 readonly visible = () => true;
165
166 /** The tab index of the tree. */
167 readonly tabIndex: SignalLike<-1 | 0> = computed(() => this.treeBehavior.tabIndex());
168
169 /** The id of the current active item. */
170 readonly activeDescendant = computed(() => this.treeBehavior.activeDescendant());
171
172 /** The direct children of the root (top-level tree items). */
173 readonly children = computed(() =>
174 this.inputs.items().filter(item => item.level() === this.level() + 1),
175 );
176
177 /** Whether the tree selection follows focus. */
178 readonly followFocus = computed(() => this.inputs.selectionMode() === 'follow');
179
180 /** Whether the tree direction is RTL. */
181 readonly isRtl = computed(() => this.textDirection() === 'rtl');
182
183 /** The key for navigating to the previous item. */
184 readonly prevKey = computed(() => {
185 if (this.inputs.orientation() === 'vertical') {
186 return 'ArrowUp';
187 }
188 return this.isRtl() ? 'ArrowRight' : 'ArrowLeft';
189 });
190
191 /** The key for navigating to the next item. */
192 readonly nextKey = computed(() => {
193 if (this.inputs.orientation() === 'vertical') {
194 return 'ArrowDown';
195 }
196 return this.isRtl() ? 'ArrowLeft' : 'ArrowRight';
197 });
198
199 /** The key for collapsing an item or moving to its parent. */
200 readonly collapseKey = computed(() => {
201 if (this.inputs.orientation() === 'horizontal') {
202 return 'ArrowUp';
203 }
204 return this.isRtl() ? 'ArrowRight' : 'ArrowLeft';
205 });
206
207 /** The key for expanding an item or moving to its first child. */

Callers

nothing calls this directly

Calls 15

_expandOrFirstChildMethod · 0.95
_collapseOrParentMethod · 0.95
gotoMethod · 0.95
signalFunction · 0.90
computedFunction · 0.90
expandSiblingsMethod · 0.80
toggleMethod · 0.65
selectMethod · 0.65
tabIndexMethod · 0.45
filterMethod · 0.45
levelMethod · 0.45
orientationMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…