MCPcopy Create free account
hub / github.com/angular/components / TabListPattern

Class TabListPattern

src/aria/private/tabs/tabs.ts:124–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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