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

Class TabListPattern

src/aria/private/tabs/tabs.ts:124–308  ·  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 /** The currently active tab. */
138 readonly activeTab: SignalLike<TabPattern | undefined>; // set from inputs
139
140 /** The currently selected tab. */
141 readonly selectedTab: WritableSignalLike<TabPattern | undefined>; // set from inputs
142
143 /** Whether the tablist is vertically or horizontally oriented. */
144 readonly orientation: SignalLike<'vertical' | 'horizontal'>; // set from inputs
145
146 /** Whether the tablist is disabled. */
147 readonly disabled: SignalLike<boolean>; // set from inputs
148
149 /** The tab index of the tablist. */
150 readonly tabIndex = computed(() => this.focusBehavior.getListTabIndex());
151
152 /** The id of the current active tab. */
153 readonly activeDescendant = computed(() => this.focusBehavior.getActiveDescendant());
154
155 /** Whether selection should follow focus. */
156 readonly followFocus = computed(() => this.inputs.selectionMode() === 'follow');
157
158 /** The key used to navigate to the previous tab in the tablist. */
159 readonly prevKey = computed(() => {
160 if (this.inputs.orientation() === 'vertical') {
161 return 'ArrowUp';
162 }
163 return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
164 });
165
166 /** The key used to navigate to the next item in the list. */
167 readonly nextKey = computed(() => {
168 if (this.inputs.orientation() === 'vertical') {
169 return 'ArrowDown';
170 }
171 return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
172 });
173
174 /** The keydown event manager for the tablist. */
175 readonly keydown = computed(() => {
176 return new KeyboardEventManager()
177 .on(
178 this.prevKey,
179 () => this._navigate(() => this.navigationBehavior.prev(), this.followFocus()),
180 {ignoreRepeat: false},
181 )

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