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

Class TabListPattern

src/aria/private/tabs/tabs.ts:123–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121
122/** Controls the state of a tablist. */
123export class TabListPattern {
124 /** The list focus behavior for the tablist. */
125 readonly focusBehavior: ListFocus<TabPattern>;
126
127 /** The list navigation behavior for the tablist. */
128 readonly navigationBehavior: ListNavigation<TabPattern>;
129
130 /** Controls expansion for the tablist. */
131 readonly expansionBehavior: ListExpansion;
132
133 /** Whether the tablist has been interacted with. */
134 readonly hasBeenInteracted = signal(false);
135
136 /** The currently active tab. */
137 readonly activeTab: SignalLike<TabPattern | undefined>; // set from inputs
138
139 /** The currently selected tab. */
140 readonly selectedTab: WritableSignalLike<TabPattern | undefined>; // set from inputs
141
142 /** Whether the tablist is vertically or horizontally oriented. */
143 readonly orientation: SignalLike<'vertical' | 'horizontal'>; // set from inputs
144
145 /** Whether the tablist is disabled. */
146 readonly disabled: SignalLike<boolean>; // set from inputs
147
148 /** The tab index of the tablist. */
149 readonly tabIndex = computed(() => this.focusBehavior.getListTabIndex());
150
151 /** The id of the current active tab. */
152 readonly activeDescendant = computed(() => this.focusBehavior.getActiveDescendant());
153
154 /** Whether selection should follow focus. */
155 readonly followFocus = computed(() => this.inputs.selectionMode() === 'follow');
156
157 /** The key used to navigate to the previous tab in the tablist. */
158 readonly prevKey = computed(() => {
159 if (this.inputs.orientation() === 'vertical') {
160 return 'ArrowUp';
161 }
162 return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
163 });
164
165 /** The key used to navigate to the next item in the list. */
166 readonly nextKey = computed(() => {
167 if (this.inputs.orientation() === 'vertical') {
168 return 'ArrowDown';
169 }
170 return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
171 });
172
173 /** The keydown event manager for the tablist. */
174 readonly keydown = computed(() => {
175 return new KeyboardEventManager()
176 .on(
177 this.prevKey,
178 () => this._navigate(() => this.navigationBehavior.prev(), this.followFocus()),
179 {ignoreRepeat: false},
180 )

Callers

nothing calls this directly

Calls 14

_navigateMethod · 0.95
openMethod · 0.95
_getItemMethod · 0.95
signalFunction · 0.90
computedFunction · 0.90
getListTabIndexMethod · 0.80
getActiveDescendantMethod · 0.80
orientationMethod · 0.45
onMethod · 0.45
prevMethod · 0.45
nextMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…