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

Class ToolbarPattern

src/aria/private/toolbar/toolbar.ts:25–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24/** Controls the state of a toolbar. */
25export class ToolbarPattern<V> {
26 /** The list behavior for the toolbar. */
27 readonly listBehavior: List<ToolbarWidgetPattern<V>, V>;
28
29 /** Whether the toolbar has been interacted with. */
30 readonly hasBeenInteracted = signal(false);
31
32 /** Whether the tablist is vertically or horizontally oriented. */
33 readonly orientation: SignalLike<'vertical' | 'horizontal'>;
34
35 /** Whether disabled items in the group should be focusable. */
36 readonly softDisabled: SignalLike<boolean>;
37
38 /** Whether the toolbar is disabled. */
39 readonly disabled = computed(() => this.listBehavior.disabled());
40
41 /** The tab index of the toolbar (if using activedescendant). */
42 readonly tabIndex = computed(() => this.listBehavior.tabIndex());
43
44 /** The id of the current active widget (if using activedescendant). */
45 readonly activeDescendant = computed(() => this.listBehavior.activeDescendant());
46
47 /** The currently active item in the toolbar. */
48 readonly activeItem = () => this.listBehavior.inputs.activeItem();
49
50 /** The key used to navigate to the previous widget. */
51 private readonly _prevKey = computed(() => {
52 if (this.inputs.orientation() === 'vertical') {
53 return 'ArrowUp';
54 }
55 return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
56 });
57
58 /** The key used to navigate to the next widget. */
59 private readonly _nextKey = computed(() => {
60 if (this.inputs.orientation() === 'vertical') {
61 return 'ArrowDown';
62 }
63 return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
64 });
65
66 /** The alternate key used to navigate to the previous widget. */
67 private readonly _altPrevKey = computed(() => {
68 if (this.inputs.orientation() === 'vertical') {
69 return this.inputs.textDirection() === 'rtl' ? 'ArrowRight' : 'ArrowLeft';
70 }
71 return 'ArrowUp';
72 });
73
74 /** The alternate key used to navigate to the next widget. */
75 private readonly _altNextKey = computed(() => {
76 if (this.inputs.orientation() === 'vertical') {
77 return this.inputs.textDirection() === 'rtl' ? 'ArrowLeft' : 'ArrowRight';
78 }
79 return 'ArrowDown';
80 });
81
82 /** The keydown event manager for the toolbar. */

Callers

nothing calls this directly

Calls 14

_groupNextMethod · 0.95
_groupPrevMethod · 0.95
selectMethod · 0.95
signalFunction · 0.90
computedFunction · 0.90
activeItemMethod · 0.80
disabledMethod · 0.45
tabIndexMethod · 0.45
orientationMethod · 0.45
onMethod · 0.45
nextMethod · 0.45
prevMethod · 0.45

Tested by

no test coverage detected